-
-
Notifications
You must be signed in to change notification settings - Fork 947
False positive "Access to an uninitialized readonly property" #10048
Copy link
Copy link
Closed
phpstan/phpstan-src
#3930Labels
Milestone
Description
Bug report
This specific false positive happens if a constructor creates a callback/closure, and that closure calls a method which accesses the readonly property.
These are the full requirements for the bug to be seen:
- A class has a readonly property.
- The property is set in the constructor.
- A method accesses that property.
- A callback/closure which calls the method is created in the constructor.
This bug started with version 1.10.23 and is still being reported with the latest version. The error isn't reported in earlier versions.
Code snippet that reproduces the problem
Expected output
PHP shouldn't report an error.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan has been a huge help, it's great at finding bugs as part of our CICD system!
Reactions are currently unavailable