Add @var tag support in dockblocks#41
Add @var tag support in dockblocks#41red-led wants to merge 1 commit intozendframework:masterfrom red-led:VarTag
Conversation
| * @param string $variableName | ||
| * @return self | ||
| */ | ||
| public function setVariableName($variableName) |
There was a problem hiding this comment.
Please remove this setter, unless strictly required. Making it private is also OK
There was a problem hiding this comment.
Variable name is allowed to be null in constructor, so there should be method to set it later. Other tags like @param or @author are working same way.
| } | ||
|
|
||
| /** | ||
| * @return string |
| /** | ||
| * @var string | ||
| */ | ||
| protected $variableName = null; |
| class VarTag extends AbstractTypeableTag implements TagInterface | ||
| { | ||
| /** | ||
| * @var string |
There was a problem hiding this comment.
May be null, so should be string|null
| } | ||
|
|
||
| /** | ||
| * @return string |
| } | ||
|
|
||
| /** | ||
| * @return string |
| */ | ||
| public function generate() | ||
| { | ||
| $output = '@var' |
| * @param array $types | ||
| * @param string $description | ||
| */ | ||
| public function __construct($variableName = null, $types = [], $description = null) |
There was a problem hiding this comment.
is $types a TypeGenerator[] here? Can we enforce that?
There was a problem hiding this comment.
No, it is string or array of strings, passed to\Zend\Code\Generator\DocBlock\Tag\AbstractTypeableTag::setTypes
| public function initialize($tagDocblockLine) | ||
| { | ||
| $match = []; | ||
| if (!preg_match('#^(.+)?(\$[\S]+)[\s]*(.*)$#m', $tagDocblockLine, $match)) { |
There was a problem hiding this comment.
the [\s]* can be simplified to \s*
|
@Ocramius, updated |
|
@red-led this is ready to go. I will still remove any premature mutability (setters) on merge, plus I'll need to rebase, since patch needs to be applied to |
…leTag` which, supports `string|string[]`
… to prevent misuse, as it is needed for the `TagManager` to work correctly
Pretty common tag for class variables.