private function processElement(ElementReflectionInterface $element) { if ($element instanceof ConstantReflectionInterface) { $this->elements[] = ['co', $element->getPrettyName()]; } elseif ($element instanceof FunctionReflectionInterface) { $this->elements[] = ['f', $element->getPrettyName()]; } elseif ($element instanceof ClassReflectionInterface) { $this->elements[] = ['c', $element->getPrettyName()]; } }
/** * @return Template */ public function loadTemplateWithElementNamespaceOrPackage(Template $template, ElementReflectionInterface $element) { if ($namespaces = $this->elementStorage->getNamespaces()) { $name = $element->getPseudoNamespaceName(); $template = $this->loadTemplateWithNamespace($template, $name, $namespaces[$name]); } elseif ($packages = $this->elementStorage->getPackages()) { $name = $element->getPseudoPackageName(); $template = $this->loadTemplateWithNamespace($template, $name, $packages[$name]); } return $template; }
private function processElement(ElementReflectionInterface $element) { if ($element instanceof ConstantReflectionInterface) { $this->elements[] = ['co', $element->getPrettyName()]; } elseif ($element instanceof FunctionReflectionInterface) { $this->elements[] = ['f', $element->getPrettyName()]; } elseif ($element instanceof ClassReflectionInterface) { $this->elements[] = ['c', $element->getPrettyName()]; foreach ($element->getOwnMethods() as $method) { $this->elements[] = ['m', $method->getPrettyName()]; } foreach ($element->getOwnProperties() as $property) { $this->elements[] = ['p', $property->getPrettyName()]; } } }
/** * @param string $definition * @param ElementReflectionInterface $reflectionElement * @return ClassReflectionInterface|ConstantReflectionInterface|FunctionReflectionInterface|NULL */ private function resolveIfParsed($definition, ElementReflectionInterface $reflectionElement) { $definition = $this->removeEndBrackets($definition); if ($class = $this->getClass($definition, $reflectionElement->getNamespaceName())) { return $class; } elseif ($constant = $this->getConstant($definition, $reflectionElement->getNamespaceName())) { return $constant; } elseif ($function = $this->getFunction($definition, $reflectionElement->getNamespaceName())) { return $function; } return null; }
/** * @return string */ public function longDescription(ElementReflectionInterface $element) { $long = $element->getLongDescription(); // Merge lines $long = preg_replace_callback('~(?:<(code|pre)>.+?</\\1>)|([^<]*)~s', function ($matches) { return !empty($matches[2]) ? preg_replace('~\\n(?:(\\s+\\n){2,})+~', ' ', $matches[2]) : $matches[0]; }, $long); return $this->doc($long, $element, true); }
private function loadUsesToReferencedElementUsedby(ElementReflectionInterface $element) { $uses = $element->getAnnotation('uses'); if ($uses === null) { return; } foreach ($uses as $value) { list($link, $description) = preg_split('~\\s+|$~', $value, 2); $resolved = $this->elementResolver->resolveElement($link, $element); if ($resolved) { $resolved->addAnnotation('usedby', $element->getPrettyName() . ' ' . $description); } } }
/** * @return string */ private function getHighlightedCodeFromElement(ElementReflectionInterface $element) { $content = file_get_contents($element->getFileName()); return $this->sourceCodeHighlighter->highlightAndAddLineNumbers($content); }
/** * @return string */ private function getElementName(ElementReflectionInterface $element) { return strtolower(strtr(ltrim($element->getName(), '_'), '_', '-')); }