-
-
Notifications
You must be signed in to change notification settings - Fork 946
Description
Bug report
I know that iterating on Generator|null is a bug, but it's not reported until level 7.
When up to level 6, PHPStan does not report a problem and should be able to understand what the iterable type will be in the case where it's not null.
Code snippet that reproduces the problem
https://phpstan.org/r/c9fc2ca5-501f-4fbe-bdcc-cf14a9f12ea9
Expected output
The dumped type should be a union of Block and *ERROR*. It may be an stdClass or it may not be iterable at all.
In addition, an error should be reported on line 18, because neither *ERROR* nor Block has a method called getPos() (definite crash).
Additional notes
I consider this a serious problem because it's an obvious bug that otherwise won't get detected until reaching level 8. This means that reaching level 6 provides a false sense of security while missing problems like this.
Did PHPStan help you today? Did it make you happy in any way?
It's greatly assisted me while updating an old project to a newer API.