示例#1
0
文件: ReturnTag.php 项目: rikaix/zf2
 /**
  * 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;
 }
示例#2
0
文件: TagManager.php 项目: rikaix/zf2
 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;
     }
 }
示例#3
0
文件: Tag.php 项目: rikaix/zf2
 /**
  * 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;
 }