New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misleading noisy errors when assigning to offsets of array properties in 1.4 #6397
Comments
This is a hard problem, already discussed in: #6367 (comment) |
I think this really needs to be addressed. I've come across multiple errors like this on 1.4, including this one that I spent a whole day staring at in utter confusion until I noticed that the property might be |
I love how precise it is! It's preventing this error: https://3v4l.org/F5MGC But I don't have ideas how to make the message clearer. |
Yeah, I get that it detected a problem. But I spent a whole day looking at errors like this trying to figure out if it was a PHPStan bug or a problem with my code. Eventually I figured out what was going on. (Turns out the problem was being caused by #6399 in my code and there weren't actually any bugs). IMO this should be reported something like |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Since 1.4, the behaviour of assigning wrong things to array offsets has changed.
Before:
Array (array<class-string<pocketmine\block\tile\Tile>, string>) does not accept string|false.
After:
Property TileFactory::$saveNames (array<class-string<Tile>, string>) does not accept array<class-string<Tile>, bool|string>.
This output is more noisy and misleading, because it suggests the property itself is being assigned to, when what's actually happening is an offset is being assigned.
For complex array types (e.g. shapes) this leads to a duplication of information that makes it very hard to see what the actual problem is.
Code snippet that reproduces the problem
https://phpstan.org/r/d44fc30b-eb39-43ad-aab1-0b0081d8da0d
The text was updated successfully, but these errors were encountered: