svnldwg / phpstan-rules

Collection of useful additional phpstan rules. Currently only one rule, which checks immutability of objects (e.g. value objects) or properties.
MIT License
7 stars 0 forks source link

Annotated properties in parent classes #4

Closed svnldwg closed 3 years ago

svnldwg commented 3 years ago

Immutability inheritance already works with class annotations in parent classes. Property annotations are not considered yet.

All non-private properties in parent classes should be considered during immutability check. Example:

class ParentClass
{
    /** @immutable */
    protected $bar;
}

class ChildClass extends ParentClass
{
    public function set()
    {
        $this->bar = true; // should throw error, because $bar is immutable
    }
}