本文整理汇总了PHP中ReflectionFunctionAbstract::returnsReference方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionFunctionAbstract::returnsReference方法的具体用法?PHP ReflectionFunctionAbstract::returnsReference怎么用?PHP ReflectionFunctionAbstract::returnsReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionFunctionAbstract
的用法示例。
在下文中一共展示了ReflectionFunctionAbstract::returnsReference方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromReflection
/**
* Creates a function signature instance from the supplied reflection.
*
* @param \ReflectionFunctionAbstract $reflection
*
* @return self
*/
public static function fromReflection(\ReflectionFunctionAbstract $reflection)
{
$returnsReference = $reflection->returnsReference();
$name = $reflection->getShortName();
$parameterExpressions = self::getParameterExpressionsFromReflection($reflection);
if ($reflection->isClosure()) {
return self::closure($returnsReference, $parameterExpressions, array_keys($reflection->getStaticVariables()));
} elseif ($reflection instanceof \ReflectionMethod) {
if ($reflection->isPublic()) {
$accessModifier = self::ACCESS_PUBLIC;
} elseif ($reflection->isProtected()) {
$accessModifier = self::ACCESS_PROTECTED;
} else {
$accessModifier = self::ACCESS_PRIVATE;
}
if ($reflection->isAbstract()) {
$polymorphModifier = self::POLYMORPH_ABSTRACT;
} elseif ($reflection->isFinal()) {
$polymorphModifier = self::POLYMORPH_FINAL;
} else {
$polymorphModifier = null;
}
return self::method($returnsReference, $accessModifier, $polymorphModifier, $reflection->isStatic(), $name, $parameterExpressions);
} else {
return self::func($returnsReference, $name, $parameterExpressions);
}
}
示例2: formatFunction
/**
* Format a function signature.
*
* @param \ReflectionFunction $reflector
*
* @return string Formatted signature.
*/
private static function formatFunction(\ReflectionFunctionAbstract $reflector)
{
return sprintf('<keyword>function</keyword> %s<function>%s</function>(%s)', $reflector->returnsReference() ? '&' : '', self::formatName($reflector), implode(', ', self::formatFunctionParams($reflector)));
}
示例3: parseCallable
/**
*
* @param EntityFunction $callable
* @param \ReflectionFunctionAbstract $reflection
* @return $this
*/
public static function parseCallable(EntityFunction $callable, \ReflectionFunctionAbstract $reflection)
{
$doc = $reflection->getDocComment();
$params = [];
if ($doc) {
$info = ToolKit::parseDoc($doc);
$callable->setDescription($info['desc']);
$callable->setReturnInfo($info['return']['type'], $reflection->returnsReference(), $info['return']['desc']);
$callable->setOptions($info['options']);
$params = $info["params"];
} else {
$info = [];
}
/* @var \ReflectionParameter[] $params */
foreach ($reflection->getParameters() as $param) {
$argument = new EntityArgument($param->name);
if (isset($params[$param->name]["desc"])) {
$argument->description = $params[$param->name]["desc"];
}
if ($callable->getLine()) {
$argument->setLine($callable->getLine());
}
$argument->setOptional($param->isOptional());
$argument->setNullAllowed($param->allowsNull());
$argument->setValue($param->isDefaultValueAvailable() ? $param->getDefaultValue() : null, $param->isPassedByReference());
$argument->setByRef($param->isPassedByReference());
/** @var \ReflectionParameter $param */
if ($param->isArray()) {
$argument->setCast(Types::ARR);
}
if ($c = $param->getClass()) {
$argument->setCast(Types::OBJECT, $c->name);
} elseif (isset($info['params'][$param->name])) {
$_type = $info['params'][$param->name]["type"];
if (strpos($_type, "|") || $_type === "mixed") {
// multiple types or mixed
$argument->setCast(Types::MIXED);
} else {
if (strpos($_type, "[]")) {
$argument->setCast(Types::ARR, rtrim($_type, '[]'));
}
if (isset(Types::$codes[$_type])) {
$argument->setCast(Types::getType($_type));
} else {
$argument->setCast(Types::OBJECT, ltrim($_type, '\\'));
}
}
} else {
$argument->warning("not documented");
}
$callable->pushArgument($argument);
}
}
示例4: matchReflector
public function matchReflector(\ReflectionFunctionAbstract $reflector)
{
$this->setReference($reflector->returnsReference());
foreach ($reflector->getParameters() as $i => $parameter) {
try {
$this->getParameterAtIndex($i)->matchReflector($parameter);
} catch (\OutOfBoundsException $e) {
$this->appendParameter(ParameterNode::fromReflector($parameter));
}
}
return $this;
}