本文整理汇总了PHP中ReflectionFunctionAbstract::getNamespaceName方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionFunctionAbstract::getNamespaceName方法的具体用法?PHP ReflectionFunctionAbstract::getNamespaceName怎么用?PHP ReflectionFunctionAbstract::getNamespaceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionFunctionAbstract
的用法示例。
在下文中一共展示了ReflectionFunctionAbstract::getNamespaceName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromReflection
/**
* Creates a function location instance from the supplied reflection.
*
* @param \ReflectionFunctionAbstract $reflection
*
* @return self
*/
public static function fromReflection(\ReflectionFunctionAbstract $reflection)
{
if ($reflection instanceof \ReflectionFunction) {
$namespace = $reflection->getNamespaceName();
} elseif ($reflection instanceof \ReflectionMethod) {
$namespace = $reflection->getDeclaringClass()->getNamespaceName();
} else {
$namespace = null;
}
return new self($reflection->getFileName(), $namespace, $reflection->getStartLine(), $reflection->getEndLine());
}
示例2: createFromNode
/**
* @param ParamNode $node
* @param ReflectionFunctionAbstract $function
* @param int $parameterIndex
* @return ReflectionParameter
*/
public static function createFromNode(ParamNode $node, ReflectionFunctionAbstract $function, $parameterIndex)
{
$param = new self();
$param->name = $node->name;
$param->function = $function;
$param->isOptional = (bool) $node->isOptional;
$param->hasDefaultValue = null !== $node->default;
$param->isVariadic = (bool) $node->variadic;
$param->isByReference = (bool) $node->byRef;
$param->parameterIndex = (int) $parameterIndex;
$param->typeHint = (new FindTypeFromAst())->__invoke($node->type, $function->getLocatedSource(), $function instanceof ReflectionMethod ? $function->getDeclaringClass()->getNamespaceName() : $function->getNamespaceName());
if ($param->hasDefaultValue) {
$param->parseDefaultValueNode($node->default);
}
$param->docBlockTypes = (new FindParameterType())->__invoke($function, $node);
return $param;
}
示例3: getTypeHint
/**
* Get the type hint declared for the parameter. This is the real type hint
* for the parameter, e.g. `method(closure $someFunc)` defined by the
* method itself, and is separate from the docblock type hints.
*
* @see getDocBlockTypes()
* @return Type
*/
public function getTypeHint()
{
$namespaceForType = $this->function instanceof ReflectionMethod ? $this->function->getDeclaringClass()->getNamespaceName() : $this->function->getNamespaceName();
return (new FindTypeFromAst())->__invoke($this->node->type, $this->function->getLocatedSource(), $namespaceForType);
}