Пример #1
0
 public function addTagPrototype(Tag $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;
     }
 }
Пример #2
0
 /**
  * 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;
 }