【问题标题】:Documentation of dereferenced closure in PHPPHP 中取消引用闭包的文档
【发布时间】:2014-05-26 17:05:42
【问题描述】:

我应该如何使用 doxygen 或 phpdocumentor 标记来记录 final_nums 常量?关闭在较旧的 phpdocumentor 中无法记录,但从 phpdocumentor2 开始,它们应该具有完整的 php 5.3 支持。为了使文档更复杂一点,通过取消引用,闭包是短暂的。

我相信生成的文档应该解释该常量由匿名函数的结果组成,该函数接受 (int)prefix 和 (string)input 的争论并返回 (int)result。

$prefix = 1234;
$input = $_GET['input'];
define( 'final_nums', call_user_func(function() use ( $prefix, $input ) {       
    $no_str = preg_replace( '/[^0-9]/', '', $input );
    $output = $prefix . $no_str;
    return $output;
}));

【问题讨论】:

    标签: php closures doxygen dereference phpdocumentor2


    【解决方案1】:

    /** * A constant that is generated based on $prefix and $input at runtime * @var int * @see $prefix * @see $input */ define( ... ); 用于实现的闭包对我来说似乎无关紧要,读者,如果我关心的是常量是什么。

    如果/当 @type 标签被实现时,它将是比 @var 更好的选择来表示数据类型。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 2011-06-24
      • 1970-01-01
      • 2022-01-20
      • 2021-06-16
      • 1970-01-01
      • 2019-08-26
      相关资源
      最近更新 更多