Inheritance: extends PHPParser_Node_Stmt
Ejemplo n.º 1
0
 public function buildPropertyObjectFromNode(PHPParser_Node_Stmt_Property $propertyNode)
 {
     $propertyName = '';
     $propertyDefault = NULL;
     foreach ($propertyNode->getProps() as $subNode) {
         if ($subNode instanceof PHPParser_Node_Stmt_PropertyProperty) {
             $propertyName = $subNode->getName();
             if ($subNode->getDefault()) {
                 $propertyDefault = $subNode->getDefault();
             }
         }
     }
     $propertyObject = new Tx_PhpParser_Domain_Model_Class_Property($propertyName);
     $propertyObject->setModifiers($propertyNode->getType());
     $propertyObject->setNode($propertyNode);
     $propertyObject->initDocComment();
     if (NULL !== $propertyDefault) {
         $propertyObject->setValue(Tx_PhpParser_Parser_Utility_NodeConverter::getValueFromNode($propertyDefault), FALSE, $propertyObject->isTaggedWith('var'));
     }
     return $propertyObject;
 }
Ejemplo n.º 2
0
 /**
  * Returns the parsed DocBlock.
  *
  * @return \phpDocumentor\Reflection\DocBlock|null
  */
 public function getDocBlock()
 {
     $doc_block = null;
     if ($comment = $this->property->getDocComment()) {
         try {
             $doc_block = new \phpDocumentor\Reflection\DocBlock((string) $comment, $this->getNamespace(), $this->getNamespaceAliases());
             $doc_block->line_number = $comment->getLine();
         } catch (\Exception $e) {
             $this->log($e->getMessage(), 2);
         }
     }
     \phpDocumentor\Plugin\EventDispatcher::getInstance()->dispatch('reflection.docblock-extraction.post', \phpDocumentor\Reflection\Events\PostDocBlockExtractionEvent::createInstance($this)->setDocblock($doc_block));
     return $doc_block;
 }
Ejemplo n.º 3
0
 protected function addProperty(\PHPParser_Node_Stmt_Property $node)
 {
     foreach ($node->props as $prop) {
         $property = new PropertyReflection($prop->name, $prop->getLine());
         $property->setModifiers($node->type);
         if ($this->context->getFilter()->acceptProperty($property)) {
             $this->context->getClass()->addProperty($property);
             $property->setDefault($prop->default);
             $comment = $this->context->getDocBlockParser()->parse($node->getDocComment(), $this->context, $property);
             $property->setDocComment($node->getDocComment());
             $property->setShortDesc($comment->getShortDesc());
             $property->setLongDesc($comment->getLongDesc());
             if ($errors = $comment->getErrors()) {
                 $this->context->addErrors((string) $property, $prop->getLine(), $errors);
             } else {
                 if ($tag = $comment->getTag('var')) {
                     $property->setHint($this->resolveHint($tag[0][0]));
                     $property->setHintDesc($tag[0][1]);
                 }
                 $property->setTags($comment->getOtherTags());
             }
         }
     }
 }
Ejemplo n.º 4
0
 private function processProperty(\PHPParser_Node_Stmt_Property $node)
 {
     $property = $node->props[0];
     $member = $this->unit->addMember($property->name);
     $this->setVariableType($member, $property->type);
     $this->setVariableDefaultValue($member, $property->default);
     $visibility = 'public';
     if ($node->isPrivate()) {
         $visibility = 'private';
     } elseif ($node->isProtected()) {
         $visibility = 'protected';
     }
     $member->setVisibility($visibility);
     $docComment = $node->getDocComment();
     if ($docComment !== NULL) {
         $block = $this->dockblocParser->parse($docComment, $this->aliasMap);
         $member->setDocBlock($block);
     }
     $member->setLine($node->getLine());
 }