Don't lose known offset-types in array_replace()#4826
Don't lose known offset-types in array_replace()#4826ondrejmirtes merged 7 commits intophpstan:2.1.xfrom
Conversation
| assertType("non-empty-array<'bar'|'foo'|int, string>", array_replace($array1, $array3)); | ||
| assertType("non-empty-array<'bar'|'foo'|int, string>", array_replace($array3, $array1)); | ||
| assertType("non-empty-array<'bar'|'foo'|int, string>&hasOffset('bar')&hasOffset('foo')", array_replace($array1, $array3)); | ||
| assertType("non-empty-array<'bar'|'foo'|int, string>&hasOffsetValue('bar', '2')&hasOffsetValue('foo', '1')", array_replace($array3, $array1)); |
There was a problem hiding this comment.
this kind of overlaps. should we do something about it, or is it fine?
There was a problem hiding this comment.
You mean the non-empty-array and the hasOffset(Value) ?
I think it's more clear this way, by being explicit.
I dunno if it's currently possible to get a dump
array<...>&hasOffset(..)
It would be weird to be able to get both array or non-empty-array in this situation.
There was a problem hiding this comment.
the type is
non-empty-array<'bar'|'foo'|int, string>&hasOffsetValue('bar', '2')&hasOffsetValue('foo', '1')
while some keys in
non-empty-array<'bar'|'foo'|int, string>
are redundant with the accessories in
hasOffsetValue('bar', '2')&hasOffsetValue('foo', '1')
|
@claudepache @VincentLanglet you might be interessted in reviewing this one |
|
Thank you! |
analog #4554