Add Type::popArray() and Type::shiftArray()#1847
Conversation
d82590f to
d925ea1
Compare
|
oh, this is more interesting after all.. here are 2 failures
|
d925ea1 to
48b3e22
Compare
src/Analyser/NodeScopeResolver.php
Outdated
There was a problem hiding this comment.
this fixes the first failure, see also #1849
at least here removing it causes a test failure. but as mentioned there - I did not fully understand it tbh, it was do-while specific though
There was a problem hiding this comment.
Yeah, I guess it makes sense, the same thing is done ($bodyScope = $bodyScope->mergeWith($scope);) before the final analysis on line 978.
48b3e22 to
5506009
Compare
| $arrayArg, | ||
| $arrayArgType, | ||
| $functionReflection->getName() === 'array_pop' ? $arrayArgType->popArray() : $arrayArgType->shiftArray(), | ||
| $scope->getNativeType($arrayArg), |
There was a problem hiding this comment.
I feel like we should get the native array type and call the same method on it too.
|
Thank you. |
|
@herndlm did you intentiomally not use the new Type methods in the array-pop and array-shift return type extension? |
|
Yes, because those return the first or last element. I mixed this up recently as well :) |
This is a boring one, but at least I could get rid of the
TypeTraverserusage. I should have never added that..I wasn't sure at first, but indeed,
array_shiftre-indexes the array and preserves the list.