/**
  * Creates a PHP parameter from reflection
  * 
  * @param \ReflectionParameter $ref
  * @return PhpParameter
  */
 public static function fromReflection(\ReflectionParameter $ref)
 {
     $parameter = new static();
     $parameter->setName($ref->name)->setPassedByReference($ref->isPassedByReference());
     if ($ref->isDefaultValueAvailable()) {
         $parameter->setDefaultValue($ref->getDefaultValue());
     }
     // find type and description in docblock
     $docblock = new Docblock($ref->getDeclaringFunction());
     $params = $docblock->getTags('param');
     $tag = $params->find($ref->name, function (ParamTag $t, $name) {
         return $t->getVariable() == '$' . $name;
     });
     if ($tag !== null) {
         $parameter->setType($tag->getType(), $tag->getDescription());
     }
     // set type if not found in comment
     if ($parameter->getType() === null) {
         if ($ref->isArray()) {
             $parameter->setType('array');
         } elseif ($class = $ref->getClass()) {
             $parameter->setType($class->getName());
         } elseif (method_exists($ref, 'isCallable') && $ref->isCallable()) {
             $parameter->setType('callable');
         }
     }
     return $parameter;
 }
    public function testTags()
    {
        $expected = '/**
 * @see https://github.com/gossi/docblock
 * @author gossi
 * @author KH
 * @since 28.5.2014
 */';
        $docblock = new Docblock($expected);
        $tags = $docblock->getTags();
        $this->assertEquals(4, $tags->size());
        $this->assertTrue($docblock->hasTag('see'));
        $this->assertTrue($docblock->hasTag('author'));
        $this->assertTrue($docblock->hasTag('since'));
        $this->assertFalse($docblock->hasTag('license'));
        $authors = $docblock->getTags('author');
        $this->assertEquals(2, $authors->size());
        $this->assertEquals($expected, $docblock->toString());
        $this->assertSame($docblock, $docblock->appendTag(ThrowsTag::create()));
        $tags = $docblock->getTags();
        $this->assertEquals(5, $tags->size());
        $this->assertTrue($docblock->hasTag('author'));
        $this->assertFalse($docblock->hasTag('moooh'));
    }