私は、データベースから変更されたプリオーダーツリートランスバーサルツリーを抽出し、コールバック関数を使用してそれをフィルタリングするメソッドを持っています。たとえば:コールバックはどのようにPHPDocする必要がありますか?
/**
* Recursive function for building the Cas_Template_TreeNode.
*
* @static
* @param array $rows
* @param callback $filter A function to filter the tree by (return a value convertible to false to remove the item from the tree)
* @return array
*/
private static function MakeTreeGivenDbRows($rows, $filter = null)
{
if ($filter === null)
{
$filter = function($unused)
{
return true;
};
}
$result = array();
$childrenCount = 0;
for ($idx = 0; $idx < count($rows); $idx += $childrenCount + 1)
{
$current = $rows[$idx];
$childrenCount = self::ChildrenCountFromRow($current);
if (!$filter($current))
{
continue;
}
$childrenStartAt = $idx + 1;
$childRows = array_slice($rows, $childrenStartAt, $childrenCount);
$children = self::MakeTreeGivenDbRows($childRows, $filter);
$result[] = new Cas_Template_TreeNode(self::MakeNodeGivenDbRow($current), $children);
}
if (empty($result))
{
return null;
}
return $result;
}
私はたPHPDocは、変数$filter
のためにどうあるべきかわからない - それは私が指示した内容で、コールバック、ですが、私はそれが正しいかどうか分かりません。
また、このコードでは、品質(またはその欠如)上の任意の他のコメントは@param
タグのドキュメントは、長い年月に更新されているようには見えない
すばらしい質問です。 – zerkms