Exemplo n.º 1
0
 /**
  * @return string
  */
 public function getDocComment()
 {
     if (!$this->node->hasAttribute('comments')) {
         return '';
     }
     /* @var \PhpParser\Comment\Doc $comment */
     $comment = $this->node->getAttribute('comments')[0];
     return $comment->getReformattedText();
 }
Exemplo n.º 2
0
 /**
  * Given a property, attempt to find the type of the property
  *
  * @param PropertyNode $node
  * @param ReflectionProperty $reflectionProperty
  * @return Type[]
  */
 public function __invoke(PropertyNode $node, ReflectionProperty $reflectionProperty)
 {
     $contextFactory = new ContextFactory();
     $context = $contextFactory->createForNamespace($reflectionProperty->getDeclaringClass()->getNamespaceName(), $reflectionProperty->getDeclaringClass()->getLocatedSource()->getSource());
     /* @var \PhpParser\Comment\Doc $comment */
     if (!$node->hasAttribute('comments')) {
         return [];
     }
     $comment = $node->getAttribute('comments')[0];
     $docBlock = new DocBlock($comment->getReformattedText(), new DocBlock\Context($context->getNamespace(), $context->getNamespaceAliases()));
     /* @var \phpDocumentor\Reflection\DocBlock\Tag\VarTag $varTag */
     $resolvedTypes = [];
     $varTags = $docBlock->getTagsByName('var');
     foreach ($varTags as $varTag) {
         $resolvedTypes = array_merge($resolvedTypes, (new ResolveTypes())->__invoke($varTag->getTypes(), $context));
     }
     return $resolvedTypes;
 }