Skip to content

@property-read allows write access when a private property of the same name exists #11241

@dotdash

Description

@dotdash

Bug report

When I declare a @property-read int $foo on a class that does not have an actual $foo Property, trying to write to the property generates an error. But if there is a private int $foo property, this error disappears, even for write accesses from outside the class.

Code snippet that reproduces the problem

https://phpstan.org/r/1d80dcca-a9f4-4dee-809b-11471e29a6f0

Expected output

Line 38 should also trigger the assign.propertyReadOnly` error.

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions