简体   繁体   中英

Changing the template code produced by Zend_Tool

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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM