Skip to content

Commit 97b7960

Browse files
committed
Fixed @method annotations with an empty argument list and description
1 parent 549d235 commit 97b7960

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

src/DocBlock/Tags/Method.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,8 @@ public static function create(
120120
)
121121
\s+
122122
)?
123-
# Legacy method name (not captured)
124-
(?:
125-
[\w_]+\(\)\s+
126-
)?
127123
# Method name
128-
([\w\|_\\\\]+)
124+
([\w_]+)
129125
# Arguments
130126
(?:
131127
\(([^\)]*)\)

tests/unit/DocBlock/Tags/MethodTest.php

+34
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,40 @@ public function testCreateMethodParenthesisMissing() : void
472472
$this->assertSame($description, $fixture->getDescription());
473473
}
474474

475+
/**
476+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
477+
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
478+
* @uses \phpDocumentor\Reflection\TypeResolver
479+
* @uses \phpDocumentor\Reflection\DocBlock\Description
480+
* @uses \phpDocumentor\Reflection\Fqsen
481+
* @uses \phpDocumentor\Reflection\Types\Context
482+
*
483+
* @covers ::create
484+
*/
485+
public function testCreateMethodEmptyArguments() : void
486+
{
487+
$descriptionFactory = m::mock(DescriptionFactory::class);
488+
$resolver = new TypeResolver();
489+
$context = new Context('');
490+
491+
$description = new Description('My Description');
492+
493+
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
494+
495+
$fixture = Method::create(
496+
'static void myMethod() My Description',
497+
$resolver,
498+
$descriptionFactory,
499+
$context
500+
);
501+
502+
$this->assertSame('static void myMethod() My Description', (string) $fixture);
503+
$this->assertSame('myMethod', $fixture->getMethodName());
504+
$this->assertEquals([], $fixture->getArguments());
505+
$this->assertInstanceOf(Void_::class, $fixture->getReturnType());
506+
$this->assertSame($description, $fixture->getDescription());
507+
}
508+
475509
/**
476510
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
477511
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory

0 commit comments

Comments
 (0)