我应该如何使用 doxygen 或 phpdocumentor 标记来记录 final_nums 常量?关闭在较旧的 phpdocumentor 中无法记录,但从 phpdocumentor2 开始,它们应该具有完整的 php 5.3 支持。为了使文档更复杂一点,通过取消引用,闭包是短暂的。
我相信生成的文档应该解释该常量由匿名函数的结果组成,该函数接受(int)前缀和(字符串)输入的争论并返回(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;
}));