0

This is a silly little thing, but I was just wondering whether there was a way to change the style of the code produced by the Zend_Tool? Specifically, the bracket style?

// from this:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

// to this
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {

Obviously it's not a huge problem, but I thought there might be some configuration for it?

nickf
  • 537,072
  • 198
  • 649
  • 721
  • I consider it bad practice to leave the opening bracket on the first row. It makes code much more readable, if matching pairs of opening and closing brackets are on the same vertical line. – markus Sep 27 '09 at 15:00
  • I know there is dispute about this but I don't see a single positive point in leaving opening brackets on the first line. It's just an old ingrained habit. but then again, this is just my opinion :) – markus Sep 27 '09 at 15:04

1 Answers1

5

Taking a look at the source of Zend_CodeGenerator_Php_Class::generate, line 466 and following (for ZF 1.9.2), you'll see something like this :

$output .= 'class ' . $this->getName();

if (null !== ($ec = $this->_extendedClass)) {
    $output .= ' extends ' . $ec;
}

$implemented = $this->getImplementedInterfaces();
if (!empty($implemented)) {
    $output .= ' implements ' . implode(', ', $implemented);
}

$output .= self::LINE_FEED . '{' . self::LINE_FEED . self::LINE_FEED;

So, I do not think this is configurable.

There might be a way, overloading some stuff via inheritance, but I don't know how you'd have your new class taken into account...


Still : the formating you want does not respect Zend Framework's Coding Standard, which states, in 4.4.1. Class Declaration :

Classes must be named according to Zend Framework's naming conventions.

The brace should always be written on the line underneath the class name.

I'm guessing it seemed logical for the guys who coded that to make it respect the coding standard of the framework itself ^^

(And, as you are developping an application using that framework, I would recommend that you'd use that standard too)

Pascal MARTIN
  • 395,085
  • 80
  • 655
  • 663