-
Notifications
You must be signed in to change notification settings - Fork 538
Do not report non existent offset for invalid ones #4385
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
Conversation
184ce9e
to
08a6ce5
Compare
Did you double check the issue bot results are intentional? |
Yes, the issue bot is misleading, |
a77fd4b
to
b2a5e81
Compare
b2a5e81
to
9e583a9
Compare
"ignorable": true | ||
}, | ||
{ | ||
"message": "Offset DateTimeImmutable does not exist on array.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As expected, I reduce the duplicates from #4387
This pull request has been marked as ready for review. |
Thank you! |
$validArrayDimType = TypeCombinator::intersect(AllowedArrayKeysTypes::getType(), $dimType); | ||
|
||
foreach ($flattenedTypes as $innerType) { | ||
$dimTypeToCheck = $innerType->isArray()->yes() ? $validArrayDimType : $dimType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only apply to array because we just have InvalidKeyInArrayDimFetchRule
.
But you considered maybe extending the rule to String.
I wonder if in another PR we should create something like
isOffsetValueTypeLegal(Type $offsetType, PHPVersion $phpVersion)
(with maybe astrict
param...)ArrayType::isOffsetValueTypeLegal rely on
AllowedArrayKeysTypes::getType`- We use isOffsetValueTypeLegal in InvalidKeyInArrayDimFetchRule
- And we use it here to filter the offsetDim
Dunno... this topic does not seems to be easy ^^'
This PR causes this error to be reported on level < 9 which is a bug: https://phpstan.org/r/bbec48eb-1e0b-4c45-830a-46792cdfba3f |
Reverting as I want to do a release. |
Indeed, MixedType shouldn't be intersected because it will transform it into an uniontype and lower the error level. |
Need #4386
Need #4387