示例#1
0
 public function __construct(\ReflectionFunctionAbstract $Reflection, callable $SourceLoader)
 {
     $this->Reflection = $Reflection;
     $this->Parameters = $this->Reflection->getParameters();
     $this->UsedVariablesMap = $this->Reflection->getStaticVariables();
     $this->SourceLoader = $SourceLoader;
 }
示例#2
0
 /**
  * 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);
 }