From 4b5594f569a66ae1c533ddbe80d80e72581c0c70 Mon Sep 17 00:00:00 2001 From: HalFtaN Date: Mon, 9 Jan 2017 12:19:56 +0800 Subject: [PATCH 1/2] Add support for `@return $this` phpdoc --- src/Padawan/Domain/Project/Node/ClassData.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Padawan/Domain/Project/Node/ClassData.php b/src/Padawan/Domain/Project/Node/ClassData.php index ce9a8e9..7500ba0 100644 --- a/src/Padawan/Domain/Project/Node/ClassData.php +++ b/src/Padawan/Domain/Project/Node/ClassData.php @@ -87,6 +87,11 @@ public function addInterface($interface) } public function addMethod(MethodData $method) { + if ($method->return instanceof FQCN) { + if ($method->return->getLast() === 'this') { + $method->return = $this->fqcn; + } + } $this->methods->add($method); } public function getMethod($methodName) From 6c22a1407f423963b37f62e0633241fc378fa361 Mon Sep 17 00:00:00 2001 From: HalFtaN Date: Mon, 9 Jan 2017 14:22:48 +0800 Subject: [PATCH 2/2] Add test for `@return $this` phpdoc --- features/class-scope-completion.feature | 86 +++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/features/class-scope-completion.feature b/features/class-scope-completion.feature index 287879f..dc41590 100644 --- a/features/class-scope-completion.feature +++ b/features/class-scope-completion.feature @@ -118,3 +118,89 @@ Feature: Class Scope | aPublicProperty | | methodOfOtherClass | | otherMethodOfOtherClass | + + Scenario: Gettings all methods and properties for $this with @return $this + Given there is a file with: + """ + method1()->" on the 18 line + And I ask for completion + Then I should get: + | Name | + | method1 | + | method2 | + | someApi | + + Scenario: Accessing only public methods and properties for return $this + Given there is a file with: + """ + method1()->" on the 16 line + And I ask for completion + Then I should get: + | Name | + | method1 | + | method2 | + | someApi |