From a788f83cf89c6656eab9fba2939bd0ea74fe95bc Mon Sep 17 00:00:00 2001 From: Daniel Rotter Date: Mon, 10 Feb 2020 14:54:19 +0100 Subject: [PATCH 1/3] Add failing testcase for long method name --- tests/unit/DocBlock/Tags/MethodTest.php | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/unit/DocBlock/Tags/MethodTest.php b/tests/unit/DocBlock/Tags/MethodTest.php index 03bd1b61..e7c21fa4 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()', (string) $fixture); + $this->assertSame('myVeryLongMethodName', $fixture->getMethodName()); + $this->assertInstanceOf(This::class, $fixture->getReturnType()); + } + /** * @return string[][] */ From fe1da2f159c7ffd0b0d34aeeb8ee2cea36dc3314 Mon Sep 17 00:00:00 2001 From: Jaapio Date: Mon, 10 Feb 2020 19:44:24 +0100 Subject: [PATCH 2/3] Build on push & pr --- .github/workflows/push.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 88e1b424..79968eaf 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,4 +1,8 @@ -on: push +on: + push: + branches: + - master + pull_request: name: Qa workflow jobs: setup: From 0cbfb85675812f1cf1c5b72cc29da0f162c2f566 Mon Sep 17 00:00:00 2001 From: Jaapio Date: Tue, 11 Feb 2020 08:53:28 +0100 Subject: [PATCH 3/3] Hand over the return types to our type resolver --- src/DocBlock/Tags/Method.php | 8 +------- tests/unit/DocBlock/Tags/MethodTest.php | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/DocBlock/Tags/Method.php b/src/DocBlock/Tags/Method.php index c7a00e4d..dbb2eba4 100644 --- a/src/DocBlock/Tags/Method.php +++ b/src/DocBlock/Tags/Method.php @@ -111,13 +111,7 @@ public static function create( # Return type (?: ( - (?:[\w\|_\\\\]*\$this[\w\|_\\\\]*) - | - (?: - (?:[\w\|_\\\\]+) - # array notation - (?:\[\])* - )* + [^\s]+ ) \s+ )? diff --git a/tests/unit/DocBlock/Tags/MethodTest.php b/tests/unit/DocBlock/Tags/MethodTest.php index e7c21fa4..8156d07e 100644 --- a/tests/unit/DocBlock/Tags/MethodTest.php +++ b/tests/unit/DocBlock/Tags/MethodTest.php @@ -368,9 +368,9 @@ public function testReturnTypeNoneWithLongMethodName() : void ); $this->assertFalse($fixture->isStatic()); - $this->assertSame('void myVeryLongMethodName()', (string) $fixture); + $this->assertSame('void myVeryLongMethodName(mixed $node)', (string) $fixture); $this->assertSame('myVeryLongMethodName', $fixture->getMethodName()); - $this->assertInstanceOf(This::class, $fixture->getReturnType()); + $this->assertInstanceOf(Void_::class, $fixture->getReturnType()); } /**