yiisoft / yii2-apidoc

Yii 2 apidoc extension.
https://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
258 stars 121 forks source link

Getter/setter methods should not affect class-defined properties #187

Closed brandonkelly closed 4 years ago

brandonkelly commented 4 years ago

If a class defines an actual property, then getter/setter methods using the same name should not have any effect on the property docs.

For example, given this class:

class Student extends BaseObject
{
    /**
     * @var int The student's birth year
     */
    public $birthYear;

    /**
     * Returns the student's birth year.
     *
     * @return int The student's birth year.
     */
    public function getBirthYear()
    {
        return true;
    }
}

Currently yii2-apidoc will document birthYear as a read-only property because it has a corresponding getter, but no setter. Which is obviously not true.

I think if a property is actually defined by a class, whether it's protected or public, then any getter/setter methods that have the same name should ignore it, and just be documented separately.

Additional info

Q A
Yii vesion 2.x
Yii APIDoc version 2.1.2
PHP version 7.4
Operating system Ubuntu