更改 Zend_Tool 生成的模板代码

发布于 2024-08-03 04:12:16 字数 275 浏览 15 评论 0原文

这是一件愚蠢的小事,但我只是想知道是否有办法改变 Zend_Tool 生成的代码的风格?具体来说,支架样式?

// from this:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

// to this
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {

显然这不是一个大问题,但我想可能有一些配置可以解决它?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆离笙 2024-08-10 04:12:16

查看 Zend_CodeGenerator_Php_Class::generate 的源代码,第 466 行和后面的(对于 ZF 1.9.2),您会看到类似这样的内容:

$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;

所以,我愿意不认为这是可配置的。

可能有一种方法,通过继承重载一些东西,但我不知道你如何考虑你的新类......

仍然:您想要的格式不遵守 Zend Framework 的编码标准,其中指出, 4.4.1。类声明

类必须根据
Zend Framework 的命名约定。

大括号应始终写在
类名称下方的行。

我猜对于编写该代码的人来说,使其尊重框架本身的编码标准似乎是合乎逻辑的 ^^

(并且,当您使用该框架开发应用程序时,我建议您使用这个标准也是如此)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文