/** * fromReflection() * * @param \Zend\Code\Reflection\ReflectionDocblockTag $reflectionTagReturn * @return \Zend\Code\Generator\DocBlock\Tag\ReturnTag */ public static function fromReflection(\Zend\Code\Reflection\DocBlock\TagInterface $reflectionTagReturn) { $returnTag = new self(); $returnTag->setName('return'); $returnTag->setDatatype($reflectionTagReturn->getType()); // @todo rename $returnTag->setDescription($reflectionTagReturn->getDescription()); return $returnTag; }
public function addTagPrototype(TagInterface $tag) { $tagName = strtolower(str_replace(array('-', '_'), '', $tag->getName())); if (in_array($tagName, $this->tagNames)) { throw new Exception\InvalidArgumentException('A tag with this name already exists in this manager'); } $this->tagNames[] = $tagName; $this->tags[] = $tag; if ($tag instanceof GenericTag) { $this->genericTag = $tag; } }
/** * fromReflection() * * @param ReflectionDocblockTag $reflectionTag * @return Tag */ public static function fromReflection(ReflectionDocblockTag $reflectionTag) { $tagName = $reflectionTag->getName(); $codeGenDocblockTag = new self(); $codeGenDocblockTag->setName($tagName); // transport any properties via accessors and mutators from reflection to codegen object $reflectionClass = new \ReflectionClass($reflectionTag); foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { if (substr($method->getName(), 0, 3) == 'get') { $propertyName = substr($method->getName(), 3); if (method_exists($codeGenDocblockTag, 'set' . $propertyName)) { $codeGenDocblockTag->{'set' . $propertyName}($reflectionTag->{'get' . $propertyName}()); } } } return $codeGenDocblockTag; }