/** * Creates a new Descriptor from the given Reflector. * * @param SeeTag $data * * @return SeeDescriptor */ public function create($data) { $descriptor = new SeeDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); // TODO: move this to the ReflectionDocBlock component // Expand FQCN part of the FQSEN $referenceParts = explode('::', $data->getReference()); $type = current($referenceParts); $type = new Collection(array($type), $data->getDocBlock() ? $data->getDocBlock()->getContext() : null); $referenceParts[0] = $type; $descriptor->setReference(implode('::', $referenceParts)); return $descriptor; }
/** * Creates a new Descriptor from the given Reflector. * * @param SeeTag $data * * @return SeeDescriptor */ public function create($data) { $descriptor = new SeeDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $reference = $data->getReference(); if (substr($reference, 0, 7) !== 'http://' && substr($reference, 0, 8) !== 'https://' && $reference !== 'self' && $reference !== '$this') { // TODO: move this to the ReflectionDocBlock component // Expand FQCN part of the FQSEN $referenceParts = explode('::', $reference); if (count($referenceParts) > 1 && $reference[0] != '\\') { $type = current($referenceParts); $type = new Collection(array($type), $data->getDocBlock() ? $data->getDocBlock()->getContext() : null); $referenceParts[0] = $type; } elseif (isset($reference[0]) && $reference[0] != '\\') { array_unshift($referenceParts, Linker::CONTEXT_MARKER); } $reference = implode('::', $referenceParts); } $descriptor->setReference($reference); return $descriptor; }
/** * @param Tag $tag * @param string $actualNamespace * * @throws \Exception */ private function findSeeDocBlock(SeeTag $tag, $actualNamespace, array $use, array $classes) { $classReference = strstr($tag->getReference(), '::', true); $methodRefrence = str_replace(array(':', '(', ')'), '', strstr($tag->getReference(), '::')); $fullClass = $this->searchClass($classReference, $actualNamespace, $use, $classes); $rc = new \ReflectionClass($fullClass); if ($rc->hasMethod($methodRefrence) === false) { throw new \Exception(sprintf('Method "%s" does not exist in "%s"', $methodRefrence, $fullClass)); } return new DocBlock($rc->getMethod($methodRefrence)->getDocComment()); }
/** * Returns the link for the given reflector. * * Because the link tag and the see tag have different methods to acquire the link text we abstract that into this * method. * * @param Tag\SeeTag|Tag\LinkTag $tagReflector * * @return string */ private function getLinkText($tagReflector) { return $tagReflector instanceof Tag\SeeTag ? $tagReflector->getReference() : $tagReflector->getLink(); }