VarTag
Is used for processing @var
, @property
and @param
tags.
/**
* @property Bar $value Some Bar thing to use
*/
class Foo
{
}
For @property
and @param
tags it’s better to use a wrapper MultiTag
, to group them in properies
and params
arrays (see MultiTag for an example).
All these three tags are already included in PhpDocumentor::tags()
, but still here’s a simple example.
$doc = (new ReflectionClass('Foo'))->getDocComment();
$customTags = [new VarTag('property', $fqsenConvertor, ['some-more' => 'data'])];
$notations = getNotations($doc, $customTags);
var_export($notations);
Result:
[
'property' => [
'type' => 'Zoo\Baz\Bar',
'name' => 'value',
'some-more' => 'data',
'description' => 'Some Bar thing to use'
]
]
$fqsenConvertor
was used to expand property type to namespaced name. Also, as you see, additional custom data can be added to result notations.