From 3113f58f452431216a6d937470c147d988d3d59e Mon Sep 17 00:00:00 2001 From: qufo Date: Thu, 8 Jan 2015 17:28:00 +0800 Subject: [PATCH] Update ModelsCommand.php , Add COMMENT info. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When define a class(table) , we will add some comment information to the property (field), the comment information was useful for coder who has bad memory.so ,I think we'd better show the comment at the end of * @property line. I'm a Chinese, most of my team was Chinese too, the comment information was written by Chinese, so , it's helpful! ------------------------- 当我们定义一个类(表)的时候,我们会给对象(字段)加上一些注释信息,这些注释信息对记忆力不好的程序员很有用,所以我认为我们可以在属性行的尾部加入注释信息 我是个中国人,我团队中的大部分人也是中国人,这些注释信息是中文写的,对他们很有帮助。 --- src/Console/ModelsCommand.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index b0f9ee9..ce04064 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -254,8 +254,8 @@ class ModelsCommand extends Command } } - - $this->setProperty($name, $type, true, true); + $comment = $column->getComment(); + $this->setProperty($name, $type, true, true,$comment); $this->setMethod( Str::camel("where_" . $name), '\Illuminate\Database\Query\Builder|\\' . get_class($model), @@ -359,8 +359,9 @@ class ModelsCommand extends Command * @param string|null $type * @param bool|null $read * @param bool|null $write + * @param string|null $comment */ - protected function setProperty($name, $type = null, $read = null, $write = null) + protected function setProperty($name, $type = null, $read = null, $write = null,$comment=null) { if (!isset($this->properties[$name])) { $this->properties[$name] = array(); @@ -377,6 +378,9 @@ class ModelsCommand extends Command if ($write !== null) { $this->properties[$name]['write'] = $write; } + if ($comment !== null ) { + $this->properties[$name]['comment'] = $comment; + } } protected function setMethod($name, $type = '', $arguments = array()) @@ -433,7 +437,8 @@ class ModelsCommand extends Command } else { $attr = 'property-read'; } - $tag = Tag::createInstance("@{$attr} {$property['type']} {$name}", $phpdoc); + $comment = isset($property['comment'])?$property['comment']:''; + $tag = Tag::createInstance("@{$attr} {$property['type']} {$name} {$comment}", $phpdoc); $phpdoc->appendTag($tag); }