Пример #1
0
 /**
  * Return an array of ReflectionClass instances for the given file. The
  * first ReflectionClass is the class contained in the given file (there
  * may be only one) additional ReflectionClass instances are the ancestors
  * of this first class.
  *
  * @param string $file
  *
  * @return ReflectionHierarchy
  */
 public function reflect($file)
 {
     $classFqn = $this->getClassNameFromFile($file);
     $hierarchy = new ReflectionHierarchy();
     if (null === $classFqn) {
         return $hierarchy;
     }
     $classHierarchy = $this->launcher->payload(__DIR__ . '/template/reflector.template', ['file' => $file, 'class' => $classFqn])->launch();
     foreach ($classHierarchy as $classInfo) {
         $reflectionClass = new ReflectionClass();
         $reflectionClass->class = $classInfo['class'];
         $reflectionClass->abstract = $classInfo['abstract'];
         $reflectionClass->comment = $classInfo['comment'];
         $reflectionClass->interfaces = $classInfo['interfaces'];
         $reflectionClass->path = $file;
         $reflectionClass->namespace = $classInfo['namespace'];
         foreach ($classInfo['methods'] as $methodInfo) {
             $reflectionMethod = new ReflectionMethod();
             $reflectionMethod->reflectionClass = $reflectionClass;
             $reflectionMethod->class = $classInfo['class'];
             $reflectionMethod->name = $methodInfo['name'];
             $reflectionMethod->isStatic = $methodInfo['static'];
             $reflectionMethod->comment = $methodInfo['comment'];
             $reflectionClass->methods[$reflectionMethod->name] = $reflectionMethod;
         }
         $hierarchy->addReflectionClass($reflectionClass);
     }
     return $hierarchy;
 }
Пример #2
0
 /**
  * Return an array of ReflectionClass instances for the given file. The
  * first ReflectionClass is the class contained in the given file (there
  * may be only one) additional ReflectionClass instances are the ancestors
  * of this first class.
  *
  * @param string $file
  *
  * @return ReflectionHierarchy
  */
 public function reflect($file)
 {
     $classFqn = $this->getClassNameFromFile($file);
     if (null === $classFqn) {
         throw new \InvalidArgumentException(sprintf('Could not find class in file "%s"', $file));
     }
     $classHierarchy = $this->launcher->payload(__DIR__ . '/template/reflector.template', array('file' => $file, 'class' => $classFqn))->launch();
     $hierarchy = new ReflectionHierarchy();
     foreach ($classHierarchy as $classInfo) {
         $reflectionClass = new ReflectionClass();
         $reflectionClass->class = $classInfo['class'];
         $reflectionClass->abstract = $classInfo['abstract'];
         $reflectionClass->comment = $classInfo['comment'];
         $reflectionClass->interfaces = $classInfo['interfaces'];
         $reflectionClass->path = $file;
         foreach ($classInfo['methods'] as $methodInfo) {
             $reflectionMethod = new ReflectionMethod();
             $reflectionMethod->class = $classInfo['class'];
             $reflectionMethod->name = $methodInfo['name'];
             $reflectionMethod->isStatic = $methodInfo['static'];
             $reflectionMethod->comment = $methodInfo['comment'];
             $reflectionClass->methods[$reflectionMethod->name] = $reflectionMethod;
         }
         $hierarchy->addReflectionClass($reflectionClass);
     }
     return $hierarchy;
 }