如何在php中记录允许的数组参数值

如何在php中记录允许的数组参数值,php,documentation,phpdoc,Php,Documentation,Phpdoc,我经常将数组作为构造函数参数传递。我应该如何记录允许的值?我尝试过几种样式,但它们在phpdoc中看起来有点混乱。确实没有“官方”的phpdoc方法来记录散列数组,但有一种方法: /** * @param array $options hash of standard options for this class: * int id the id of whatever object * string name name of whoever it is * array

我经常将数组作为构造函数参数传递。我应该如何记录允许的值?我尝试过几种样式,但它们在phpdoc中看起来有点混乱。

确实没有“官方”的phpdoc方法来记录散列数组,但有一种方法:

/**
 * @param array $options hash of standard options for this class:
 *    int id the id of whatever object
 *    string name name of whoever it is
 *    array sub_option hash of sub options:
 *        int num number description for this index
 *    bool is_good should we do this or not?
 */
 function __construct( $options ){
 }

我认为最好明确地定义你想要接收的参数,而不是传递一个数组。如果你有很多参数,考虑建立一个单独的对象。