我在我的 PHP 应用程序中使用了几个关联数组,并且我正在使用 PHP 文档器来注释我的源代码。我从来没有真正为数组中的数组指定注释,但现在我需要这样做并且不知道如何。
$array = array('id' => 'test', 'class' => 'tester', 'options' => array('option1' => 1, 'option2' => 2))
对于 @var
和 @param
注释,如何以正确的方式注释此数组?
我可以这样做,但我不知道这是否正确:
@param string $array['id']
@param string $array['class']
@param int $array['options']['option1']
但是如何为 @var
部分执行此操作?
最佳答案
您无法记录每个键,但是 you can tell phpDocumentor what type it is .
你可以这样做:
/**
* Form the array like this:
* <code>
* $array = array(
* 'id' => 'foo', // the id
* 'class' => 'myClass', // the class
* );
*
* </code>
*
* @var array[string]string
*/
$array;
关于php - PHP Documentor 中的注释关联数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2713710/