【问题标题】:How should I document allowable array param values in php [closed]我应该如何在 php 中记录允许的数组参数值 [关闭]
【发布时间】:2012-09-09 05:32:06
【问题描述】:

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

【问题讨论】:

  • 我认为明确定义要接收的参数可能比传递数组更好。
  • 如果您有很多参数,请考虑构建一个单独的对象。

标签: php documentation phpdoc


【解决方案1】:

确实没有“官方”的 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 ){
 }

【讨论】:

    猜你喜欢
    • 2015-02-26
    • 1970-01-01
    • 2010-09-12
    • 1970-01-01
    • 2015-05-03
    • 1970-01-01
    • 1970-01-01
    • 2015-06-29
    • 1970-01-01
    相关资源
    最近更新 更多