Add new ArrayUnpackingRule#856
Conversation
|
Hi, I think we have to acknowledge multiple things here:
So I suggest this:
If you're unsure about bleeding edge, you can code the rule as normal and I'll configure it in a later commit :) Thank you! |
|
@canvural If you ever feel like finishing this, I'm looking forward to it! :) |
Yes, in my to-do list. I'll definitely do something about this when I have the time. Hope it's ok if this stays in draft. |
ddd20b4 to
95d480b
Compare
8adfab3 to
a582a5d
Compare
|
@ondrejmirtes It looks like there is already an error reported for all the things Also the invalid usage ( So the current rule in this PR seems sufficient? |
Yeah, but on PHP 8.0 PHPStan should complain about array with string keys being unpacked. Am I right? |
conf/config.level3.neon
Outdated
There was a problem hiding this comment.
Can you please adapt this similarly to this commit? 7627b52
Oh right, that's what this PR does. I need coffee. |
|
Hmm. Looks like no: https://3v4l.org/7lTWP Only for PHP < 8 |
a582a5d to
9edb368
Compare
9edb368 to
0b2cc87
Compare
0b2cc87 to
4373952
Compare
|
Did a couple more adjustments: https://github.com/phpstan/phpstan-src/pull/856/commits |
|
Thank you! |
|
not sure why yet, but the test from this PR errors on macOS with php 8.1.2 |
|
Fixed: e131e35 |
|
Turns out there was a feature request for this :) phpstan/phpstan#5764 |
Before PHP 8.1, unpacking an array that contains string keys results in fatal error: https://3v4l.org/A4gqa
This PR adds a rule that can check this.
Not sure if this rule would be too annoying or not. All the
mixedorarray-keykeyed arrays that being unpacked would error now. Which sounds in line with the runtime though.