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

"Missing @property annotations" inspection improvements #31

Open
brandonkelly opened this issue Jul 29, 2018 · 0 comments
Open

"Missing @property annotations" inspection improvements #31

brandonkelly opened this issue Jul 29, 2018 · 0 comments

Comments

@brandonkelly
Copy link
Collaborator

Before I get into the actual FR, some definitions:

  • Getter: A getX() method on a class that extends yii\base\BaseObject, without any required arguments, which yii\base\BaseObject::__get() will call when $obj->x is accessed.

    // valid:
    public function getAuthor()
    public function getAuthor($arg = 'default')
    
    // invalid:
    public function getauthor() // lowercase 'a'
    public function getAuthor($arg) // $arg is required
  • Setter: A setX() method on a class that extends yii\base\BaseObject, with one required argument (the first one), which yii\base\BaseObject::__set() will call when $obj->x is set to something.

    // valid:
    public function setAuthor($arg)
    public function setAuthor($arg1, $arg2 = 'default')
    
    // invalid:
    public function setauthor() // lowercase 'a'
    public function setAuthor() // no required argument
    public function setAuthor($arg1, $arg2) // $arg2 is required

If a getter exists but no corresponding setter, the "Missing @Property annotations" inspection should create a @property-read tag instead of @property.

If a setter exists but no corresponding getter, then a @property-write tag should be created instead of @property.

If both exist, then continue to create a @property tag.

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

No branches or pull requests

2 participants