我应该如何使用氧或phpdocumentor标记记录final_nums常数?闭包在旧的phpdocumentor中是不可记录的,但从phpdocumentor2开始,他们应该有完整的php 5.3支持。为了使文档更复杂一点,由于解引用,闭包的寿命很短。
我相信生成的文档应该解释该常量是由一个匿名函数的结果组成的,该函数接受(int)前缀和(string)输入的参数,并返回(int)结果。
$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;
}));
/**
* A constant that is generated based on $prefix and $input at runtime
* @var int
* @see $prefix
* @see $input
*/
define( ... );
作为读者,如果我关心的是常量是什么,那么用于实现的闭包对我来说似乎无关紧要。
如果/当实现@type
标记时,它将比@var
标记更好地表示数据类型。