Ejemplo n.º 1
0
    /**
     * @depends testConstructWithTagsOnly
     * @covers \Barryvdh\Reflection\DocBlock::getTagsByName
     * 
     * @return void
     */
    public function testGetTagsByNameMultipleMatch()
    {
        $fixture = <<<DOCBLOCK
/**
 * @param string
 * @param int
 * @return void
 */
DOCBLOCK;
        $object = new DocBlock($fixture);
        $this->assertEmpty($object->getTagsByName('category'));
        $this->assertCount(1, $object->getTagsByName('return'));
        $this->assertCount(2, $object->getTagsByName('param'));
    }
Ejemplo n.º 2
0
 protected function detectMethodsFromDoc(ReflectionClass $reflection)
 {
     $docBlock = new DocBlock($reflection);
     $methods = $docBlock->getTagsByName('method');
     foreach ($methods as $method) {
         $this->methods[] = new MethodTag($method, $this->alias, $reflection, $method->getMethodName(), $this->interfaces);
     }
 }
Ejemplo n.º 3
0
 /**
  * Normalize the return tag (make full namespace, replace interfaces)
  *
  * @param DocBlock $phpdoc
  */
 protected function normalizeReturn(DocBlock $phpdoc)
 {
     //Get the return type and adjust them for beter autocomplete
     $returnTags = $phpdoc->getTagsByName('return');
     if ($returnTags) {
         /** @var ReturnTag $tag */
         $tag = reset($returnTags);
         // Get the expanded type
         $returnValue = $tag->getType();
         // Replace the interfaces
         foreach ($this->interfaces as $interface => $real) {
             $returnValue = str_replace($interface, $real, $returnValue);
         }
         // Set the changed content
         $tag->setContent($returnValue . ' ' . $tag->getDescription());
         $this->return = $returnValue;
     } else {
         $this->return = null;
     }
 }
Ejemplo n.º 4
0
 /**
  * Get method return type based on it DocBlock comment
  *
  * @param \ReflectionMethod $reflection
  *
  * @return null|string
  */
 protected function getReturnTypeFromDocBlock(\ReflectionMethod $reflection)
 {
     $type = null;
     $phpdoc = new DocBlock($reflection);
     if ($phpdoc->hasTag('return')) {
         $type = $phpdoc->getTagsByName('return')[0]->getContent();
     }
     return $type;
 }