Skip to content

False-positive "property.uninitializedReadonly" when used indirectly by anonymous function #11828

@cziegenberg

Description

@cziegenberg

Bug report

In the linked example, the error "Access to an uninitialized readonly property Dummy::$foo." is reported (property.uninitializedReadonly), although it's initialized.

It's caused by an anonymous function that indirectly (!) accesses this property using a getter. (A direct access of the property is not reported.)

Code snippet that reproduces the problem

https://phpstan.org/r/e1c7cdb9-bf5e-40f9-b6e0-54a5649ed2ca

Expected output

[OK] No errors

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

PHPStan is great and helps a lot! Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions