コード例 #1
0
ファイル: Backend.php プロジェクト: rafasashi/ApiGen
 /**
  * @return ClassReflectionInterface[]
  */
 protected function parseClassLists()
 {
     $this->declared = array_flip(array_merge(get_declared_classes(), get_declared_interfaces()));
     foreach ($this->getNamespaces() as $namespace) {
         foreach ($namespace->getClasses() as $name => $ref) {
             $class = $this->reflectionFactory->createFromReflection($ref);
             $this->allClasses[self::TOKENIZED_CLASSES][$name] = $class;
             if (!$class->isDocumented()) {
                 continue;
             }
             $this->loadParentClassesAndInterfacesFromClassReflection($ref);
         }
     }
     foreach ($this->allClasses[self::TOKENIZED_CLASSES] as $class) {
         if (!$class->isDocumented()) {
             continue;
         }
         foreach ($class->getOwnMethods() as $method) {
             $this->processFunction($method);
         }
         foreach ($class->getOwnProperties() as $property) {
             $this->loadAnnotationFromReflection($class, $property->getAnnotations(), 'var');
         }
     }
     foreach ($this->getFunctions() as $function) {
         $this->processFunction($function);
     }
     array_walk_recursive($this->allClasses, function (&$reflection) {
         if (!$reflection instanceof ReflectionClass) {
             $reflection = $this->reflectionFactory->createFromReflection($reflection);
         }
     });
     return $this->allClasses;
 }
コード例 #2
0
 /**
  * @param string $annotation
  * @param string $annotationName
  * @return MagicPropertyReflectionInterface[]
  */
 private function processMagicPropertyAnnotation($annotation, $annotationName)
 {
     if (!preg_match(self::PATTERN_PROPERTY, $annotation, $matches)) {
         return [];
     }
     list(, $typeHint, $name, $shortDescription) = $matches;
     $startLine = $this->getStartLine($annotation);
     $properties = [];
     $properties[$name] = $this->reflectionFactory->createPropertyMagic(['name' => $name, 'typeHint' => $typeHint, 'shortDescription' => str_replace("\n", ' ', $shortDescription), 'startLine' => $startLine, 'endLine' => $startLine + substr_count($annotation, "\n"), 'readOnly' => $annotationName === 'property-read', 'writeOnly' => $annotationName === 'property-write', 'declaringClass' => $this->classReflection]);
     return $properties;
 }