Don't report "no value type specified in iterable type array&callable"#5565
Don't report "no value type specified in iterable type array&callable"#5565staabm merged 14 commits intophpstan:2.1.xfrom
Conversation
|
You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x. |
|
Also we could improve IntersectionType getIterableKeyType and ValueType if the type is array and callable. |
That's not enough, because it won't report |
I opened the issue about the fact it doesn't report an error on the line So the current state of this PR doesn't solve it @staabm |
|
I'd be interested why the line isn't reported there, seems like deficiency of ConstantArrayType::accepts(). |
@VincentLanglet running https://phpstan.org/r/c90e4fe4-2ce7-4be3-8529-ae517dd5c445 locally I get a error on line 13 (even on 2.1.x) |
|
ok its weird. the error is visible on level 7,8,9 - but not on level 10 |
|
@VincentLanglet I think we should merge the inference improvements here and investigate the missing error on level 10 separately |
| if ($type->isCallable()->yes() && $type->isArray()->yes()) { | ||
| return $type; | ||
| } |
There was a problem hiding this comment.
Three question:
- Does it still report something like
(array&callable(array): array)which should report the param/return type of the callable ? - Does the
isArray()->yes()check needed ? - Should it be after the ConditionalType in case of some conditionalType which is a callable ?
There was a problem hiding this comment.
- Does it still report something like
(array&callable(array): array)which should report the param/return type of the callable ?
while I feel such a type will be pretty rare, fixing it was easy enough
- Does the
isArray()->yes()check needed ?
I think so. we explicitly check this combination in more places.
- Should it be after the ConditionalType in case of some conditionalType which is a callable ?
the fix for 1) added a explicit check for IntersectionType. that way it can not accidentally match ConditionalType anymore
I agree it's better to solve the missing error level on another PR |
|
Dunno if ondrej'll want to give a review on this |
refs phpstan/phpstan#14549