function importVarType(Property $prop)
 {
     $prop->getDocComment();
     $comment = $prop->getDocComment();
     if ($comment) {
         $str = $comment->getText();
         if (count($prop->props) >= 1) {
             try {
                 $docBlock = $this->factory->create($str, $this->getDocBlockContext());
                 /** @var Var_[] $types */
                 $types = $docBlock->getTagsByName("var");
                 if (count($types) > 0) {
                     $type = strval($types[0]->getType());
                     if (!empty($type)) {
                         if ($type[0] == '\\') {
                             $type = substr($type, 1);
                         }
                         $prop->props[0]->setAttribute("namespacedType", strval($type));
                     }
                 }
             } catch (\InvalidArgumentException $e) {
                 // Skip it.
             }
         }
     }
 }
Пример #2
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());
 }
 /**
  * @inheritDoc
  */
 public function getDocComment()
 {
     $docBlock = $this->propertyTypeNode->getDocComment();
     return $docBlock ? $docBlock->getText() : false;
 }
 /**
  * @param Node\Stmt\Property $node
  */
 protected function parseClassPropertyNode(Node\Stmt\Property $node)
 {
     foreach ($node->props as $property) {
         $this->structuralElements[$this->currentStructuralElement->namespacedName->toString()]['properties'][] = ['name' => $property->name, 'startLine' => $node->getLine(), 'isPublic' => $node->isPublic(), 'isPrivate' => $node->isPrivate(), 'isStatic' => $node->isStatic(), 'isProtected' => $node->isProtected(), 'docComment' => $node->getDocComment() ? $node->getDocComment()->getText() : null];
     }
 }
Пример #5
0
 protected function addProperty(PropertyNode $node)
 {
     foreach ($node->props as $prop) {
         $property = new PropertyReflection($prop->name, $prop->getLine());
         $property->setModifiers($node->type);
         $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()) {
             $property->setErrors($errors);
         } else {
             if ($tag = $comment->getTag('var')) {
                 $property->setHint($this->resolveHint($tag[0][0]));
                 $property->setHintDesc($tag[0][1]);
             }
             $property->setTags($comment->getOtherTags());
         }
         if ($this->context->getFilter()->acceptProperty($property)) {
             $this->context->getClass()->addProperty($property);
             if ($errors) {
                 $this->context->addErrors((string) $property, $prop->getLine(), $errors);
             }
         }
     }
 }
 public function addProperty(PropertyNode $node)
 {
     foreach ($node->props as $prop) {
         $property = new ReflectionProperty($prop->name);
         $property->setStartLine((int) $node->getAttribute('startLine'));
         $property->setEndLine((int) $node->getAttribute('endLine'));
         $property->setDocComment((string) $node->getDocComment());
         $property->setStatic((bool) $node->isStatic());
         if (!is_null($prop->default)) {
             $value = $this->resolveValue($prop->default);
             $property->setDefault(strtolower(gettype($value)), $value);
         }
         if ($node->isPrivate()) {
             $property->setVisibility(ReflectionProperty::IS_PRIVATE);
         } elseif ($node->isProtected()) {
             $property->setVisibility(ReflectionProperty::IS_PROTECTED);
         } else {
             $property->setVisibility(ReflectionProperty::IS_PUBLIC);
         }
         $this->context->getReflection()->addProperty($property);
     }
 }