-
Notifications
You must be signed in to change notification settings - Fork 439
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
array_slice() returns non-empty array for existing offsets and positive limit #3121
Conversation
if ($offsetType !== null | ||
&& $valueType->hasOffsetValueType($offsetType)->yes() | ||
&& ($limitType === null || IntegerRangeType::fromInterval(1, null)->isSuperTypeOf($limitType)->yes()) | ||
) { | ||
return $valueType; | ||
} |
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.
the actual fix.
all changes above are just refactoring.
This pull request has been marked as ready for review. |
]; | ||
assertType("array{'zib', 'zib 2'}", $list); | ||
shuffle($list); | ||
assertType("non-empty-array<0|1, 'zib'|'zib 2'>&list", $list); |
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.
I think this PR can't work as is, because the type after shuffle
is already not precise enough.
at this point we don't know anymore, that all keys will always exist.
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.
implemented a more generic approach with #3124
closes phpstan/phpstan#10721