diff --git a/src/DocBlock/Tags/Method.php b/src/DocBlock/Tags/Method.php index c7a00e4d..30ff1c80 100644 --- a/src/DocBlock/Tags/Method.php +++ b/src/DocBlock/Tags/Method.php @@ -117,7 +117,7 @@ public static function create( (?:[\w\|_\\\\]+) # array notation (?:\[\])* - )* + )*+ ) \s+ )? diff --git a/tests/unit/DocBlock/Tags/MethodTest.php b/tests/unit/DocBlock/Tags/MethodTest.php index 03bd1b61..8156d07e 100644 --- a/tests/unit/DocBlock/Tags/MethodTest.php +++ b/tests/unit/DocBlock/Tags/MethodTest.php @@ -342,6 +342,37 @@ public function testReturnTypeThis() : void $this->assertInstanceOf(This::class, $fixture->getReturnType()); } + /** + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Method:: + * @uses \phpDocumentor\Reflection\TypeResolver + * @uses \phpDocumentor\Reflection\DocBlock\Description + * @uses \phpDocumentor\Reflection\Types\Context + * + * @covers ::create + */ + public function testReturnTypeNoneWithLongMethodName() : void + { + $descriptionFactory = m::mock(DescriptionFactory::class); + $resolver = new TypeResolver(); + $context = new Context(''); + + $description = new Description(''); + + $descriptionFactory->shouldReceive('create')->with('', $context)->andReturn($description); + + $fixture = Method::create( + 'myVeryLongMethodName($node)', + $resolver, + $descriptionFactory, + $context + ); + + $this->assertFalse($fixture->isStatic()); + $this->assertSame('void myVeryLongMethodName(mixed $node)', (string) $fixture); + $this->assertSame('myVeryLongMethodName', $fixture->getMethodName()); + $this->assertInstanceOf(Void_::class, $fixture->getReturnType()); + } + /** * @return string[][] */