本文整理汇总了PHP中ReflectionObject::getParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionObject::getParameters方法的具体用法?PHP ReflectionObject::getParameters怎么用?PHP ReflectionObject::getParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionObject
的用法示例。
在下文中一共展示了ReflectionObject::getParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Process to get reflection from file
*
* @return void
* @throws ComponentException
*/
public function process()
{
// workaround for get reflection of closure function
$bootstrap = $view = $module = $controller = null;
/** @var \Closure|object $closure */
$closure = (include $this->file);
if (!is_callable($closure)) {
throw new ComponentException("There is no callable structure in file `{$this->file}`");
}
if ($closure instanceof \Closure) {
$reflection = new \ReflectionFunction($closure);
} else {
$reflection = new \ReflectionObject($closure);
}
// check and normalize params by doc comment
$docComment = $reflection->getDocComment();
// get all options by one regular expression
if (preg_match_all('/\\s*\\*\\s*\\@([a-z0-9-_]+)\\s+(.*).*\\s+/i', $docComment, $matches)) {
foreach ($matches[1] as $i => $key) {
$this->setOption($key, $matches[2][$i]);
}
}
// init routes
$this->initRoute();
// parameters available for Closure only
if ($reflection instanceof \ReflectionFunction) {
// get params and convert it to simple array
$reflectionParams = $reflection->getParameters();
// setup params and optional params
foreach ($reflectionParams as $param) {
$name = $param->getName();
// if some function params is missed in description
if (!isset($this->params[$name])) {
$this->params[$name] = null;
}
if ($param->isOptional()) {
$this->values[$name] = $param->getDefaultValue();
}
}
}
}