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 wants to merge 6 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 |
| return $this->intersectTypes(static fn (Type $type): Type => $type->getIterableValueType()); | ||
| $result = $this->intersectTypes(static fn (Type $type): Type => $type->getIterableValueType()); | ||
| if ($this->isCallable()->yes() && $this->isArray()->yes()) { | ||
| return TypeCombinator::intersect($result, new UnionType([new ObjectWithoutClassType(), new StringType()])); |
There was a problem hiding this comment.
do empty-callable strings exist? or can we make this non-empty?
refs phpstan/phpstan#14549