本文整理汇总了PHP中ReflectionFunctionAbstract::isUserDefined方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionFunctionAbstract::isUserDefined方法的具体用法?PHP ReflectionFunctionAbstract::isUserDefined怎么用?PHP ReflectionFunctionAbstract::isUserDefined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionFunctionAbstract
的用法示例。
在下文中一共展示了ReflectionFunctionAbstract::isUserDefined方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructs a FunctionParser from a reflected function. Triggers all code parsing from the constructor.
*
* @param \ReflectionFunctionAbstract $reflection The reflected function or method.
*/
public function __construct(\ReflectionFunctionAbstract $reflection)
{
if (!$reflection->isUserDefined()) {
throw new \InvalidArgumentException('You can only parse the code of user-defined functions.');
}
$this->reflection = $reflection;
$this->tokenizer = $this->fetchTokenizer();
$this->parameters = $this->fetchParameters();
$this->code = $this->parseCode();
$this->body = $this->parseBody();
$this->context = $this->parseContext();
}
示例2: LoadSourceLines
private function LoadSourceLines(\ReflectionFunctionAbstract $Reflection)
{
if (!$Reflection->isUserDefined()) {
throw new Functional\FunctionException('Cannot parse function: Function must be user defined');
}
$FileName = $Reflection->getFileName();
if (!file_exists($FileName)) {
throw new Functional\FunctionException('Cannot parse function: Function does not belong to a valid file (cannot be eval\'d code)');
}
$SourceLines = [];
$File = new \SplFileObject($Reflection->getFileName());
$StartLine = $Reflection->getStartLine() - 2;
$File->seek($StartLine);
$EndLine = $Reflection->getEndLine() - 2;
while ($File->key() <= $EndLine) {
$SourceLines[] = trim($File->fgets());
}
unset($File);
$FirstLine =& $SourceLines[0];
$FirstLine = substr($FirstLine, stripos($FirstLine, 'function'));
$LastLine =& $SourceLines[count($SourceLines) - 1];
$LastLine = substr($LastLine, 0, strrpos($LastLine, '}') + 1);
return array_filter($SourceLines);
}
示例3: __construct
/**
* Constructor.
*
* @param string|array $function Defining function/method
* @param string $paramName Parameter name
* @param \TokenReflection\Broker $broker Reflection broker
* @param \ReflectionFunctionAbstract $parent Parent reflection object
*/
public function __construct($function, $paramName, Broker $broker, InternalReflectionFunctionAbstract $parent)
{
parent::__construct($function, $paramName);
$this->broker = $broker;
$this->userDefined = $parent->isUserDefined();
}