-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#1174Labels
Milestone
Description
Bug report
When accessing an optional class property with the null coalescing operator, phpstan does not recognize this as a reading operation, and the error Property XYZ is never read, only written. is reported.
These reported issues might be a similar (same?) problem, but not sure:
#6026
#3659
Code snippet that reproduces the problem
https://phpstan.org/r/2c837a4e-382c-4e83-af54-62716f0ccd94
I also added different approaches in the snippet below which are working. So it seems the issue is related to the null coalescing operator.
(The same behavior occurs with any object not only stdClass - just used it for simplicity in the playground)
Expected output
The class property is used - so the phpstan error should not be reported.
Did PHPStan help you today? Did it make you happy in any way?
Yes - did also help me yesterday and the day before and ... 🙇
enduro44