Make NonEmptyArrayType::toArray() return $this#2349
Make NonEmptyArrayType::toArray() return $this#2349ondrejmirtes merged 4 commits intophpstan:1.10.xfrom zonuexe:fix/9208
NonEmptyArrayType::toArray() return $this#2349Conversation
|
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. |
There was a problem hiding this comment.
array_slice() can return empty arrays. https://3v4l.org/8VGrv
|
This pull request has been marked as ready for review. |
There was a problem hiding this comment.
I'm trying to make a non-empty-array&array<T> into an array<T>. Isn't it a union?
There was a problem hiding this comment.
So you mean that you want an array that’s non-empty to no longer be non-empty? I’m afraid you need to recreate it from scratch by doing new ArrayType.
There was a problem hiding this comment.
The file needs to have namespace Bug9208.
There was a problem hiding this comment.
The file isn't referenced in NodeScopeResolverTest
There was a problem hiding this comment.
Please use PHPStan\Testing\assertType in a use function statement.
There was a problem hiding this comment.
seems this assertion fails atm in CI
| assertType('list', array_slice($b, 1)); | |
| assertType('list<mixed>', array_slice($b, 1)); |
|
This pull request has been marked as ready for review. |
|
@ondrejmirtes Could you please review this PR? |
|
Ah interesting, this is the same problem I found independently via #2451 (comment) but with a different solution that not just only removes that one accessory |
|
There's a much easier solution to make a non-empty array possibly empty again :) 9e84671 |
|
Thank you! |
|
Oh wow, so you actually planted it in my brain two months ago :D Well I'm a bit embarassed now :D |
close phpstan/phpstan#9208