本文整理汇总了PHP中XPClass::detailsForMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP XPClass::detailsForMethod方法的具体用法?PHP XPClass::detailsForMethod怎么用?PHP XPClass::detailsForMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPClass
的用法示例。
在下文中一共展示了XPClass::detailsForMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verify
/**
* Verifies a reflection function or method
*
* @param php.ReflectionFunctionAbstract $value
* @param [lang.Type] $signature
* @param function(string): var $value A function to invoke when verification fails
* @param php.ReflectionClass $class Class to get details from, optionally
* @return var
*/
protected function verify($r, $signature, $false, $class = null)
{
if (null !== $signature && sizeof($signature) < $r->getNumberOfRequiredParameters()) {
return $false('Required signature length mismatch, expecting ' . sizeof($signature) . ', have ' . $r->getNumberOfParameters());
}
$details = $class ? XPClass::detailsForMethod($class->getName(), $r->getName()) : null;
if (isset($details[DETAIL_RETURNS])) {
$returns = Type::forName($details[DETAIL_RETURNS]);
if (!$this->returns->equals($returns) && !$this->returns->isAssignableFrom($returns)) {
return $false('Return type mismatch, expecting ' . $this->returns->getName() . ', have ' . $returns->getName());
}
}
if (null === $signature) {
return true;
}
$params = $r->getParameters();
foreach ($signature as $i => $type) {
if (!isset($params[$i])) {
return $false('No parameter #' . ($i + 1));
}
if (isset($details[DETAIL_ARGUMENTS][$i])) {
$param = Type::forName($details[DETAIL_ARGUMENTS][$i]);
if (!$type->isAssignableFrom($param)) {
return $false('Parameter #' . ($i + 1) . ' not a ' . $param->getName() . ' type: ' . $type->getName());
}
} else {
$param = $params[$i];
if ($param->isArray()) {
if (!$type->equals(Primitive::$ARRAY) && !$type instanceof ArrayType && !$type instanceof MapType) {
return $false('Parameter #' . ($i + 1) . ' not an array type: ' . $type->getName());
}
} else {
if ($param->isCallable()) {
if (!$type instanceof FunctionType) {
return $false('Parameter #' . ($i + 1) . ' not a function type: ' . $type->getName());
}
} else {
if (null !== ($class = $param->getClass())) {
if (!$type->isAssignableFrom(new XPClass($class))) {
return $false('Parameter #' . ($i + 1) . ' not a ' . $class->getName() . ': ' . $type->getName());
}
}
}
}
}
}
return true;
}
示例2: getAnnotations
/**
* Retrieve all of a method's annotations
*
* @return [:var] annotations
*/
public function getAnnotations()
{
$details = XPClass::detailsForMethod($this->_reflect->getDeclaringClass(), $this->_reflect->getName());
return $details ? $details[DETAIL_ANNOTATIONS] : [];
}
示例3: getAnnotations
/**
* Retrieve all of a method's annotations
*
* @return var[] annotations
*/
public function getAnnotations()
{
$n = '$' . $this->_reflect->getName();
if (!($details = XPClass::detailsForMethod($this->_details[0], $this->_details[1])) || !isset($details[DETAIL_TARGET_ANNO][$n])) {
// Unknown or unparseable
return array();
}
return $details[DETAIL_TARGET_ANNO][$n];
}