How can I specify array of objects in PhpDoc [dupl

2020-04-06 01:04发布

Possible Duplicate:
PHPDoc type hinting for array of objects?

I use PhpDocumentor2 for generating documentation. I searched for this subject but I can't find specific rule for it. For Example I have class which name is AddressField and I want to specify my $addressFields as array of AddressField objects.

/**
 * @var AddressField[]
 */
private $addressFields;

标签: php phpdoc
1条回答
女痞
2楼-- · 2020-04-06 01:52

phpdoc themselves describe the use of arrays here:

1.4.4. Arrays

  • undefined: @return array
  • single type: @return int[]
  • multi type: @return (int|string)[]

The same should apply to variable definitions:

/* @var $arr Type[] */
查看更多
登录 后发表回答