Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codestyle fixes. Adding missed phpDoc. className -> static in methods… #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ValeriyMaslenikov
Copy link

… which returns $this.

Hi guys. To use correct autocomplete and type highlighting in IDE, like PhpStorm let's use static keyword instead of class name in @return block.

In this case IDE will notify us that methodFromB() doesn't exist, because it will expect that method iWillReturnThis returns class A:

class A {
 /**
  * @return A
  */
  public function iWillReturnThis() { 
    return $this; 
  }
} 

class B extends A {
  public function methodFromB() { }
}

(new B())->iWillReturnThis()->methodFromB()

In this case it works well:

class A {
 /**
  * @return static
  */
  public function iWillReturnThis() { 
    return $this; 
  }
} 
...

And to make fluent interface highlighting works well with public properties, let's use phpDoc @var near property declaration, like:

class A {
  /** @var B */
  public $B;
}
class B {
  public function method();
}

(new A())->B->method()

@eric-urban
Copy link
Contributor

@ValeriyMaslenikov thanks for the suggestions! We will keep these in mind for a future release.

Copy link

@ColleenKeegan ColleenKeegan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return $this

@eric-urban
Copy link
Contributor

@ValeriyMaslenikov thanks again for the feedback. We resolved most PHP doc issues in version 13.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants