Retain list type via array_push() and array_unshift()#2451
Conversation
|
You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x. |
dbc40d6 to
53b3eee
Compare
|
Ha, I just found that the array_slice return type extension is using update: this all feels dirty, maybe new type methods for push, unshift and slice or so are needed after all, but that feels like overhead... let me know what you prefer or if more info is needed please |
53b3eee to
d0c4702
Compare
|
rebased with the trick the boss came up with in 9e84671 to make the array non-non-empty again (why did I not think of this..) now I'm happy with this :) |
|
Thank you! :) |
Closes phpstan/phpstan#8449
it has been a while :) I know I have still 2 open PRs, but I didn't feel like finishing them yet. soon™
I was wondering why the array here is even re-created like that. The reason is that this is after the isIterableAtLeastOnce / optional check and the re-creation is just there to remove a NonEmptyArrayType. So if there would be a simpler/better way of removing it (maybe calling
->popArray()but I'm not sure, that feels like a hack), the list would not be removed and this new code would not be needed 🤔another more explicit way might be to intersect the union of
->getArrays()with aTypeUtils::getAccessoryTypes()where NonEmptyArrayType is filtered away. also feels ugly. I'm not a 100% happy with any of the solutions so far.. like e.g.