Beispiel #1
0
 /**
  * fromReflection()
  *
  * @param ReflectionDocBlockTag $reflectionTagLicense
  * @return LicenseTag
  */
 public static function fromReflection(ReflectionDocBlockTag $reflectionTagLicense)
 {
     $returnTag = new self();
     $returnTag->setName('license');
     $returnTag->setUrl($reflectionTagLicense->getUrl());
     $returnTag->setDescription($reflectionTagLicense->getDescription());
     return $returnTag;
 }
Beispiel #2
0
 /**
  * fromReflection()
  *
  * @param ReflectionDocBlockTag $reflectionTagReturn
  * @return ReturnTag
  */
 public static function fromReflection(ReflectionDocBlockTag $reflectionTagReturn)
 {
     $returnTag = new self();
     $returnTag->setName('return');
     $returnTag->setDatatype($reflectionTagReturn->getType());
     // @todo rename
     $returnTag->setDescription($reflectionTagReturn->getDescription());
     return $returnTag;
 }
Beispiel #3
0
 /**
  * fromReflection()
  *
  * @param ReflectionDocBlockTag $reflectionTagParam
  * @return ParamTag
  */
 public static function fromReflection(ReflectionDocBlockTag $reflectionTagParam)
 {
     $paramTag = new self();
     $paramTag->setName('param');
     $paramTag->setDatatype($reflectionTagParam->getType());
     // @todo rename
     $paramTag->setParamName($reflectionTagParam->getVariableName());
     $paramTag->setDescription($reflectionTagParam->getDescription());
     return $paramTag;
 }
Beispiel #4
0
 /**
  * @param TagInterface $tag
  * @throws Exception\InvalidArgumentException
  */
 public function addTagPrototype(TagInterface $tag)
 {
     $tagName = 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;
     }
 }
Beispiel #5
0
 /**
  * Build a Tag generator object from a reflection object
  *
  * @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;
 }
Beispiel #6
0
 /**
  * @param ReflectionTagInterface $reflectionTag
  * @return TagInterface
  */
 public function createTagFromReflection(ReflectionTagInterface $reflectionTag)
 {
     $tagName = $reflectionTag->getName();
     /* @var TagInterface $newTag */
     $newTag = $this->getClonedPrototype($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($newTag, 'set' . $propertyName)) {
                 $newTag->{'set' . $propertyName}($reflectionTag->{'get' . $propertyName}());
             }
         } elseif (substr($method->getName(), 0, 2) == 'is') {
             $propertyName = ucfirst($method->getName());
             if (method_exists($newTag, 'set' . $propertyName)) {
                 $newTag->{'set' . $propertyName}($reflectionTag->{$method->getName()}());
             }
         }
     }
     return $newTag;
 }
 /**
  * @param  ReflectionDocBlockTag $reflectionTagParam
  * @return AuthorTag
  */
 public static function fromReflection(ReflectionDocBlockTag $reflectionTagParam)
 {
     $authorTag = new self();
     $authorTag->setName('author')->setAuthorName($reflectionTagParam->getType())->setAuthorEmail($reflectionTagParam->getVariableName())->setDescription($reflectionTagParam->getDescription());
     return $authorTag;
 }