我正试图找出如何在phpdocumentor的类中正确地记录数组属性。
例如:
<?php
class foo {
/**
* This holds something important
* @var string
*/
protected $junk;
/**
* This holds an important array of strings
* @var ???????
*/
protected $stuff = array();
// ...
}
?>
我在phpdoc手册中找不到任何关于数组属性的内容。
/** @var array */
用于protected $stuff
是正确的语法。@var的phpDocumentor手册页面显示"数据类型应该是有效的PHP类型(int、string、bool等)",而"array"就是这样一个有效的PHP类型。
一些IDE也开始识别/** @var ElementType[] */
,以表示"这是一个数组,其元素都是ElementType类型"。此语法将在即将发布的phpDocumentor版本中提供。