Skip to content

Commit

Permalink
Merge pull request #93 from halftan/feature/support-return-this-phpdoc
Browse files Browse the repository at this point in the history
Feature/support return this phpdoc
  • Loading branch information
mkusher authored Jan 9, 2017
2 parents a926bb6 + 6c22a14 commit 427bb26
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
86 changes: 86 additions & 0 deletions features/class-scope-completion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
<?php
class SomeClass
{
/**
* @return $this
*/
public function method1()
{
}
public function method2()
{
}
private function somePrivateMethod()
{
}
private $someDep;
public $someApi;
}
"""
When I type "$this->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:
"""
<?php
class SomeOtherClass
{
public function methodOfOtherClass()
{
}
public function otherMethodOfOtherClass()
{
}
private function privateMethodOfOtherClass()
{
}
public $aPublicProperty;
}
class SomeClass
{
/**
* @return $this
*/
public function method1()
{
}
public function method2()
{
}
private function somePrivateMethod()
{
}
private $someDep;
public $someApi;
}
"""
When I type "$a = new SomeClass;" on the 15 line
And I type "$a->method1()->" on the 16 line
And I ask for completion
Then I should get:
| Name |
| method1 |
| method2 |
| someApi |
5 changes: 5 additions & 0 deletions src/Padawan/Domain/Project/Node/ClassData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 427bb26

Please sign in to comment.