/** * @param ClassReflectionInterface $reflectionClass * @param bool $isDocumented * @param array $methods * @return MagicMethodReflectionInterface[] */ private function extractOwnFromClass(ClassReflectionInterface $reflectionClass, $isDocumented, array $methods) { foreach ($reflectionClass->getOwnMagicMethods() as $method) { if ($this->canBeExtracted($isDocumented, $methods, $method)) { $methods[$method->getName()] = $method; } } return $methods; }
/** * @param ClassReflectionInterface $classReflection * @param bool $isDocumented * @param array $properties * @return MagicPropertyReflectionInterface[] */ private function extractOwnFromClass(ClassReflectionInterface $classReflection, $isDocumented, array $properties) { foreach ($classReflection->getOwnMagicProperties() as $property) { if ($this->canBeExtracted($isDocumented, $properties, $property)) { $properties[$property->getName()] = $property; } } return $properties; }
/** * @param string $annotation * @return int */ private function getStartLine($annotation) { $doc = $this->classReflection->getDocComment(); $tmp = $annotation; if ($delimiter = strpos($annotation, "\n")) { $tmp = substr($annotation, 0, $delimiter); } return $this->classReflection->getStartLine() + substr_count(substr($doc, 0, strpos($doc, $tmp)), "\n"); }
/** * {@inheritdoc} */ public function extractFromReflection(ClassReflectionInterface $reflectionClass) { $this->reflectionClass = $reflectionClass; $methods = []; if ($reflectionClass->hasAnnotation('method')) { foreach ($reflectionClass->getAnnotation('method') as $annotation) { $methods += $this->processMagicMethodAnnotation($annotation); } } return $methods; }
/** * {@inheritdoc} */ public function getUsedMethods() { $usedMethods = []; foreach ($this->classReflection->getMethods() as $method) { if ($method->getDeclaringTraitName() === NULL || $method->getDeclaringTraitName() === $this->classReflection->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; }
/** * @param string $definition * @param ClassReflectionInterface $reflectionClass * @param int $pos * @return ClassReflectionInterface */ private function resolveContextForClassProperty($definition, ClassReflectionInterface $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; }
/** * @param ClassReflectionInterface $class * @param string $name * @return bool */ private function isAllowedIndirectImplementer(ClassReflectionInterface $class, $name) { if ($class->isDocumented() && $class->implementsInterface($name) && !in_array($name, $class->getOwnInterfaceNames())) { return true; } return false; }
/** * @return string */ private function getTypeByReflection(ClassReflectionInterface $reflection) { if ($reflection->isInterface()) { return ElementsInterface::INTERFACES; } elseif ($reflection->isTrait()) { return ElementsInterface::TRAITS; } elseif ($reflection->isException()) { return ElementsInterface::EXCEPTIONS; } else { return ElementsInterface::CLASSES; } }
/** * @param string $name * @param ClassReflectionInterface|MethodReflectionInterface|InNamespaceInterface $reflection * @return string */ private function getClassFqn($name, $reflection) { return Resolver::resolveClassFqn($name, $reflection->getNamespaceAliases(), $reflection->getNamespaceName()); }
/** * @return array */ private function sortElements(array $elements, array $allElements, ClassReflectionInterface $classReflection) { if (!empty($elements)) { ksort($elements); $allElements[$classReflection->getName()] = array_values($elements); } return $allElements; }
/** * @return string */ public function createForProperty(PropertyReflectionInterface $property, ClassReflectionInterface $class = null) { $className = $class !== null ? $class->getName() : $property->getDeclaringClassName(); return $this->createForClass($className) . '#' . ($property->isMagic() ? 'm' : '') . '$' . $property->getName(); }
/** * @return bool */ private function isReservedClass(ClassReflectionInterface $class) { $reservedClasses = ['stdClass', 'Closure', 'Directory']; return in_array($class->getName(), $reservedClasses); }