是否有用于记录功能的语法,该函数采用单个配置数组,而不是单个参数?
我正在考虑使用类似于以下机制的CodeIgniter样式库:
//
// Library definition
//
class MyLibrary {
var $foo;
var $bar;
var $baz;
// ... and many more vars...
/* Following is how CodeIgniter documents their built-in libraries,
* which is mostly useless. AFAIK they should be specifying a name
* and description for their @param (which they don't) and omitting
* @return for constructors
*/
/**
* @access public
* @param array
* @return void
*/
function MyLibrary($config = array()) {
foreach ($config as $key => $value) {
$this->$key = $value;
}
}
}
//
// Library usage:
//
// Iniitialize our configuration parameters
$config['foo'] = 'test';
$config['bar'] = 4;
$config['baz'] = array('x', 'y', 'z');
$x = new MyLibrary($config);
?>
所以我的问题是,有没有一些限制的方式记录配置数组,而不仅仅是纯文本描述?实际指定一个适当的@param [type] [name] [desc],允许PHPDoc解析出有用的值?
除此之外,CodeIgniter真的只是覆盖那些通过$config数组传入的值,它们有效地允许你隐藏私有成员.我不是粉丝,但我被困住了.