/**
  * @param ReflectionClass $reflectionClass
  * @param bool $isDocumented
  * @param array $methods
  * @return ReflectionMethodMagic[]
  */
 private function extractOwnFromClass(ReflectionClass $reflectionClass, $isDocumented, array $methods)
 {
     foreach ($reflectionClass->getOwnMagicMethods() as $method) {
         if ($this->canBeExtracted($isDocumented, $methods, $method)) {
             $methods[$method->getName()] = $method;
         }
     }
     return $methods;
 }
 /**
  * @param string $annotation
  * @return int
  */
 private function getStartLine($annotation)
 {
     $doc = $this->reflectionClass->getDocComment();
     $tmp = $annotation;
     if ($delimiter = strpos($annotation, "\n")) {
         $tmp = substr($annotation, 0, $delimiter);
     }
     return $this->reflectionClass->getStartLine() + substr_count(substr($doc, 0, strpos($doc, $tmp)), "\n");
 }
 /**
  * @param ReflectionClass $reflectionClass
  * @param bool $isDocumented
  * @param array $properties
  * @return ReflectionPropertyMagic[]
  */
 private function extractOwnFromClass(ReflectionClass $reflectionClass, $isDocumented, array $properties)
 {
     foreach ($reflectionClass->getOwnMagicProperties() as $property) {
         if ($this->canBeExtracted($isDocumented, $properties, $property)) {
             $properties[$property->getName()] = $property;
         }
     }
     return $properties;
 }
 /**
  * @return array {[ traitName => ReflectionMethod[] ]}
  */
 public function getUsedMethods()
 {
     $usedMethods = [];
     foreach ($this->reflectionClass->getMethods() as $method) {
         if ($method->getDeclaringTraitName() === NULL || $method->getDeclaringTraitName() === $this->reflectionClass->getName()) {
             continue;
         }
         $usedMethods[$method->getDeclaringTraitName()][$method->getName()]['method'] = $method;
         if ($method->getOriginalName() !== NULL && $method->getOriginalName() !== $method->getName()) {
             $usedMethods[$method->getDeclaringTraitName()][$method->getName()]['aliases'][$method->getName()] = $method;
         }
     }
     return $usedMethods;
 }
 /**
  * @return string
  */
 public function getFileName()
 {
     return $this->declaringClass->getFileName();
 }
 /**
  * @return array
  */
 private function sortElements(array $elements, array $allElements, ReflectionClass $reflectionClass)
 {
     if (!empty($elements)) {
         ksort($elements);
         $allElements[$reflectionClass->getName()] = array_values($elements);
     }
     return $allElements;
 }
 /**
  * @param ReflectionClass $class
  * @param string $name
  * @return bool
  */
 private function isAllowedIndirectImplementer(ReflectionClass $class, $name)
 {
     if ($class->isDocumented() && $class->implementsInterface($name) && !in_array($name, $class->getOwnInterfaceNames())) {
         return TRUE;
     }
     return FALSE;
 }
Ejemplo n.º 8
0
 /**
  * Prepares and returns used class lists.
  *
  * @return array
  */
 protected function parseClassLists()
 {
     $allClasses = array(self::TOKENIZED_CLASSES => array(), self::INTERNAL_CLASSES => array(), self::NONEXISTENT_CLASSES => array());
     $declared = array_flip(array_merge(get_declared_classes(), get_declared_interfaces()));
     foreach ($this->getNamespaces() as $namespace) {
         foreach ($namespace->getClasses() as $name => $trClass) {
             $class = new Reflection\ReflectionClass($trClass, $this->generator);
             $allClasses[self::TOKENIZED_CLASSES][$name] = $class;
             if (!$class->isDocumented()) {
                 continue;
             }
             foreach (array_merge($trClass->getParentClasses(), $trClass->getInterfaces()) as $parentName => $parent) {
                 if ($parent->isInternal()) {
                     if (!isset($allClasses[self::INTERNAL_CLASSES][$parentName])) {
                         $allClasses[self::INTERNAL_CLASSES][$parentName] = $parent;
                     }
                 } elseif (!$parent->isTokenized()) {
                     if (!isset($allClasses[self::NONEXISTENT_CLASSES][$parentName])) {
                         $allClasses[self::NONEXISTENT_CLASSES][$parentName] = $parent;
                     }
                 }
             }
         }
     }
     foreach ($allClasses[self::TOKENIZED_CLASSES] as $class) {
         if (!$class->isDocumented()) {
             continue;
         }
         foreach ($class->getOwnMethods() as $method) {
             $allClasses = $this->processFunction($declared, $allClasses, $method);
         }
         foreach ($class->getOwnProperties() as $property) {
             $annotations = $property->getAnnotations();
             if (!isset($annotations['var'])) {
                 continue;
             }
             foreach ($annotations['var'] as $doc) {
                 foreach (explode('|', preg_replace('~\\s.*~', '', $doc)) as $name) {
                     if ($name = rtrim($name, '[]')) {
                         $name = Resolver::resolveClassFQN($name, $class->getNamespaceAliases(), $class->getNamespaceName());
                         $allClasses = $this->addClass($declared, $allClasses, $name);
                     }
                 }
             }
         }
     }
     foreach ($this->getFunctions() as $function) {
         $allClasses = $this->processFunction($declared, $allClasses, $function);
     }
     array_walk_recursive($allClasses, function (&$reflection, $name, Generator $generator) {
         if (!$reflection instanceof Reflection\ReflectionClass) {
             $reflection = new Reflection\ReflectionClass($reflection, $generator);
         }
     }, $this->generator);
     return $allClasses;
 }
Ejemplo n.º 9
0
 /**
  * @param string $name
  * @param ReflectionClass|ReflectionMethod $reflection
  * @return string
  */
 private function getClassFqn($name, $reflection)
 {
     return Resolver::resolveClassFqn($name, $reflection->getNamespaceAliases(), $reflection->getNamespaceName());
 }
 /**
  * @param string $definition
  * @param ReflectionClass $reflectionClass
  * @param int $pos
  * @return ReflectionClass
  */
 private function resolveContextForClassProperty($definition, ReflectionClass $reflectionClass, $pos)
 {
     // Class::something or Class->something
     if (strpos($definition, 'parent::') === 0 && ($parentClassName = $reflectionClass->getParentClassName())) {
         return $this->getClass($parentClassName);
     } elseif (strpos($definition, 'self::') !== 0) {
         return $this->resolveContextForSelfProperty($definition, $pos, $reflectionClass);
     }
     return $reflectionClass;
 }
Ejemplo n.º 11
0
 /**
  * Returns a link to property in class summary file.
  *
  * @param \ApiGen\Reflection\ReflectionProperty $property Property reflection
  * @param \ApiGen\Reflection\ReflectionClass $class Property declaring class
  * @return string
  */
 public function getPropertyUrl(Reflection\ReflectionProperty $property, Reflection\ReflectionClass $class = null)
 {
     $className = null !== $class ? $class->getName() : $property->getDeclaringClassName();
     return $this->getClassUrl($className) . '#' . ($property->isMagic() ? 'm' : '') . '$' . $property->getName();
 }
Ejemplo n.º 12
0
 /**
  * Returns a link to class summary file.
  *
  * @param string|\ApiGen\Reflection\ReflectionClass $class Class reflection or name
  * @return string
  */
 public function getClassUrl($class)
 {
     $className = $class instanceof Reflection\ReflectionClass ? $class->getName() : $class;
     return sprintf($this->config->template->templates->main->class->filename, $this->urlize($className));
 }
 /**
  * @return string
  */
 private function getTypeByReflection(ReflectionClass $reflection)
 {
     if ($reflection->isInterface()) {
         return Elements::INTERFACES;
     } elseif ($reflection->isTrait()) {
         return Elements::TRAITS;
     } elseif ($reflection->isException()) {
         return Elements::EXCEPTIONS;
     } else {
         return Elements::CLASSES;
     }
 }
 /**
  * @return string
  */
 public function createForProperty(ReflectionProperty $property, ReflectionClass $class = NULL)
 {
     $className = $class !== NULL ? $class->getName() : $property->getDeclaringClassName();
     return $this->createForClass($className) . '#' . ($property->isMagic() ? 'm' : '') . '$' . $property->getName();
 }
 /**
  * @return bool
  */
 private function isReservedClass(ReflectionClass $class)
 {
     $reservedClasses = ['stdClass', 'Closure', 'Directory'];
     return in_array($class->getName(), $reservedClasses);
 }