個々のパラメーターではなく、単一の構成配列を取る関数を文書化するための構文はありますか?
私は特に、これに似たメカニズムを使用する CodeIgniter スタイルのライブラリについて考えています。
<?php
//
// 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 配列を介して渡された値で独自の値を上書きするだけであり、効果的にプライベート メンバーを上書きできます。私はファンではありませんが、私はそれに立ち往生しています。