/** * @return string */ private function getFunctionFqnName(ReflectionFunction $reflection) { return $reflection->getNamespaceName() . '\\' . $reflection->getName(); }
/** * Sorts functions by FQN. * * @param \ApiGen\Reflection\ReflectionFunction $one * @param \ApiGen\Reflection\ReflectionFunction $two * @return integer */ private function sortFunctions(Reflection\ReflectionFunction $one, Reflection\ReflectionFunction $two) { return strcasecmp($one->getNamespaceName() . '\\' . $one->getName(), $two->getNamespaceName() . '\\' . $two->getName()); }
/** * Processes a function/method and adds classes from annotations to the overall class array. * * @param array $declared Array of declared classes * @param array $allClasses Array with all classes parsed so far * @param \ApiGen\Reflection\ReflectionFunction|\TokenReflection\IReflectionFunctionBase $function Function/method reflection * @return array */ private function processFunction(array $declared, array $allClasses, $function) { static $parsedAnnotations = array('param', 'return', 'throws'); $annotations = $function->getAnnotations(); foreach ($parsedAnnotations as $annotation) { if (!isset($annotations[$annotation])) { continue; } foreach ($annotations[$annotation] as $doc) { foreach (explode('|', preg_replace('~\\s.*~', '', $doc)) as $name) { if ($name) { $name = Resolver::resolveClassFQN(rtrim($name, '[]'), $function->getNamespaceAliases(), $function->getNamespaceName()); $allClasses = $this->addClass($declared, $allClasses, $name); } } } } foreach ($function->getParameters() as $param) { if ($hint = $param->getClassName()) { $allClasses = $this->addClass($declared, $allClasses, $hint); } } return $allClasses; }
/** * Processes a function/method and adds classes from annotations to the overall class array. * * @param ReflectionMethod|ReflectionFunction $reflection */ private function processFunction($reflection) { $annotations = $reflection->getAnnotations(); foreach (['param', 'return', 'throws'] as $annotation) { $this->loadAnnotationFromReflection($reflection, $annotations, $annotation); } foreach ($reflection->getParameters() as $parameter) { if ($hint = $parameter->getClassName()) { $this->addClass($hint); } } }
/** * @param ReflectionClass|ReflectionParameter|ReflectionFunction|ReflectionElement $reflectionElement * @return ReflectionClass|ReflectionFunction */ private function correctContextForParameterOrClassMember($reflectionElement) { if ($reflectionElement instanceof ReflectionParameter && $reflectionElement->getDeclaringClassName() === NULL) { // Parameter of function in namespace or global space return $this->getFunction($reflectionElement->getDeclaringFunctionName()); } elseif ($reflectionElement instanceof ReflectionMethod || $reflectionElement instanceof ReflectionParameter || $reflectionElement instanceof ReflectionConstant && $reflectionElement->getDeclaringClassName() !== NULL || $reflectionElement instanceof ReflectionProperty) { // Member of a class return $this->getClass($reflectionElement->getDeclaringClassName()); } return $reflectionElement; }
/** * Returns a link to function summary file. * * @param \ApiGen\Reflection\ReflectionFunction $function Function reflection * @return string */ public function getFunctionUrl(Reflection\ReflectionFunction $function) { return sprintf($this->config->template->templates->main->function->filename, $this->urlize($function->getName())); }
/** * @return string */ public function createForFunction(ReflectionFunction $function) { return sprintf($this->configuration->getOption(CO::TEMPLATE)['templates']['function']['filename'], Filters::urlize($function->getName())); }