本文整理汇总了PHP中ReflectionFunctionAbstract::isClosure方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionFunctionAbstract::isClosure方法的具体用法?PHP ReflectionFunctionAbstract::isClosure怎么用?PHP ReflectionFunctionAbstract::isClosure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionFunctionAbstract
的用法示例。
在下文中一共展示了ReflectionFunctionAbstract::isClosure方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFunctionName
private function getFunctionName(\ReflectionFunctionAbstract $reflectionFunction)
{
if ($reflectionFunction->isClosure()) {
return sprintf('closure defined in %s at line %d', $reflectionFunction->getFileName(), $reflectionFunction->getStartLine());
} elseif ($reflectionFunction instanceof \ReflectionMethod) {
return sprintf('%s::%s', $reflectionFunction->getDeclaringClass()->getName(), $reflectionFunction->getName());
}
return $reflectionFunction->getName();
}
示例2: __toString
/**
* Print the signature of the target action.
*
* @return string
*/
public function __toString()
{
if ($this->target instanceof \ReflectionMethod) {
return sprintf('%s->%s()', $this->target->getDeclaringClass()->name, $this->target->name);
}
if ($this->target instanceof \ReflectionFunction && !$this->target->isClosure()) {
return $this->target->getName() . '()';
}
return '*closure*';
}
示例3: fromReflection
/**
* Creates a function scope instance from the supplied reflection and callable.
*
* @param \ReflectionFunctionAbstract $reflection
* @param callable $callable
*
* @return self
*/
public static function fromReflection(\ReflectionFunctionAbstract $reflection, callable $callable)
{
if (is_array($callable)) {
/** @var $reflection \ReflectionMethod */
$thisObject = is_object($callable[0]) ? $callable[0] : null;
$scopeType = $reflection->getDeclaringClass()->getName();
} elseif (is_object($callable) && !$callable instanceof \Closure) {
/** @var $reflection \ReflectionMethod */
$thisObject = $callable;
$scopeType = $reflection->getDeclaringClass()->getName();
} elseif ($reflection->isClosure()) {
$thisObject = $reflection->getClosureThis();
$scopeClass = $reflection->getClosureScopeClass();
$scopeType = $scopeClass === null ? null : $scopeClass->getName();
} else {
$thisObject = null;
$scopeType = null;
}
$variableTable = $reflection->getStaticVariables();
return new self($thisObject, $scopeType, $variableTable);
}
示例4: getCalledMethod
/**
* Get called method from abstract reflection function
*
* @param \ReflectionFunctionAbstract $method
* @param bool $closureInfo
*
* @return string
*/
public static function getCalledMethod(\ReflectionFunctionAbstract $method, $closureInfo = true)
{
if ($method->isClosure()) {
if ($closureInfo) {
return sprintf('Closure [%s:%d]', $method->getFileName(), $method->getStartLine());
}
return 'Closure';
}
if ($method instanceof \ReflectionMethod) {
return sprintf('%s::%s', $method->getDeclaringClass()->getName(), $method->getName());
}
return $method->getName();
}
示例5:
function it_returns_its_line_number_as_zero_if_constructed_with_closure(\ReflectionFunctionAbstract $function)
{
$function->isClosure()->willReturn(true);
$this->getLineNumber()->shouldReturn(0);
}
示例6: prepareCallbackArguments
/**
* Merges found arguments with multiliners and maps them to the function callback signature.
*
* @param ContextInterface $context context instance
* @param \ReflectionFunctionAbstract $refl callback reflection
* @param array $arguments found arguments
* @param array $multiline multiline arguments of the step
*
* @return array
*/
private function prepareCallbackArguments(ContextInterface $context, \ReflectionFunctionAbstract $refl, array $arguments, array $multiline)
{
$parametersRefl = $refl->getParameters();
if ($refl->isClosure()) {
array_shift($parametersRefl);
}
$resulting = array();
foreach ($parametersRefl as $num => $parameterRefl) {
if (isset($arguments[$parameterRefl->getName()])) {
$resulting[] = $arguments[$parameterRefl->getName()];
} elseif (isset($arguments[$num])) {
$resulting[] = $arguments[$num];
}
}
foreach ($multiline as $argument) {
$resulting[] = $argument;
}
return $resulting;
}
示例7: getCallbackSignature
protected function getCallbackSignature(\ReflectionFunctionAbstract $ref)
{
if ($ref instanceof \ReflectionMethod) {
return $ref->getDeclaringClass()->name . '->' . $ref->name . '()';
}
if ($ref->isClosure()) {
return '*closure*';
}
return $ref->name . '()';
}
示例8: getLineNumber
/**
* @return int
*/
public function getLineNumber()
{
return $this->function->isClosure() ? 0 : $this->function->getStartLine();
}