/** * @return ReflectionMethodMagic[]|array */ public function extractFromClass(ReflectionClass $reflectionClass) { $methods = []; if ($parentClass = $reflectionClass->getParentClass()) { $methods += $this->extractFromParentClass($parentClass, $reflectionClass->isDocumented()); } if ($traits = $reflectionClass->getTraits()) { $methods += $this->extractFromTraits($traits, $reflectionClass->isDocumented()); } return $methods; }
/** * @return ReflectionMethod[]|array */ public function getTraitMethods() { $methods = []; foreach ($this->originalReflection->getTraitMethods($this->reflectionClass->getVisibilityLevel()) as $method) { $apiMethod = $this->reflectionClass->getReflectionFactory()->createFromReflection($method); if (!$this->reflectionClass->isDocumented() || $apiMethod->isDocumented()) { /** @var ReflectionMethod $method */ $methods[$method->getName()] = $apiMethod; } } return $methods; }
/** * @return bool */ private function canBeProcessed(ReflectionClass $reflection) { if (!$reflection->isMain()) { return FALSE; } if (!$reflection->isDocumented()) { return FALSE; } if (isset($this->processed[$reflection->getName()])) { return FALSE; } return TRUE; }
/** * @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; }
/** * 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; }