protected function loadParameters($className, $method)
{
// dig for data on the chosen method, in the chosen class
$parameters = array();
$reflectionMethod = new \ReflectionMethod($className, $method);
$PHPDoc = $reflectionMethod->getDocComment();
/*
* This regex filters out all parameters, along with their PHPDoc. We use this instead
* of $reflectionMethod->getParameters(), since that returns ReflectionParameter objects
* that, rather shamefully, do not contain PHPDoc.
*/
preg_match_all('/@param[\\s\\t]+(.*)[\\s\\t]+\\$(.*)[\\s\\t]+(.*)$/Um', $PHPDoc, $matches);
if (array_key_exists(0, $matches) && empty($matches[0])) {
return;
}
// we have to build up a custom stack of parameters
foreach ($matches[0] as $i => $row) {
$name = $matches[2][$i];
if ($name === 'language') {
continue;
}
$parameters[] = array('name' => $name, 'label' => $name . '-' . mt_rand(1, 99999), 'optional' => mb_substr_count($matches[2][$i], '[optional]') > 0, 'description' => $matches[3][$i]);
}
return $parameters;
}