#6840 Report useless array filter#1077
Conversation
8317d8e to
91c6a48
Compare
|
I'm looking at this - it's really nice, Some observations that would make this even better:
|
That's what this PR checks for. Do you mean the opposite? Calling
|
|
Yes, that's what I meant, the rule should report both always-truthy and always-falsy arrays :) |
|
USE_BOTH without a callback only uses the first arg (= value) AFAIK, see also https://github.com/phpstan/phpstan-src/blob/1.4.10/tests/PHPStan/Analyser/data/array-filter.php#L36 But better double-check :) if the referenced test is wrong, I need to fix smth in the ArrayFilter extension |
|
I checked, passing
|
|
Ah maybe that explains why the key mode test above my rererence also looks weird 😅 would be interesting if and how it filters |
91c6a48 to
58fc6cf
Compare
|
It doesn't filter at all: I've added support for reporting arrays with only falsey values. |
8d6237f to
4ac9256
Compare
|
|
|
The failure is definitely related as the file contains this: Feel free to modify the file to contains something that's valid, like |
4ac9256 to
713dc09
Compare
|
Turns out |
bb60b4d to
7f6853a
Compare
7f6853a to
b29a267
Compare
|
I pushed some extra commits to adjust this to my taste. |
|
Thank you. |
|
Also to keep the BC promise (https://phpstan.org/user-guide/backward-compatibility-promise) I had to do this: 7627b52
|
|
@leongersen fyi I think null callables would work fine, they only work since PHP 8 and weirdly only ever filter by value (= ignore any given mode) See https://3v4l.org/Cj17A |
New branch based on 1.5.x, I could not reopen #1076.
Implements phpstan/phpstan#6840.