@@ -26,11 +26,14 @@ public function __construct(
26
26
{
27
27
}
28
28
29
- public function handleAnyArray (Type $ arrayType , Type $ columnType , ?Type $ indexType , Scope $ scope ): Type
29
+ /**
30
+ * @return array{Type, TrinaryLogic}
31
+ */
32
+ public function getReturnValueType (Type $ arrayType , Type $ columnType , Scope $ scope ): array
30
33
{
31
34
$ iterableAtLeastOnce = $ arrayType ->isIterableAtLeastOnce ();
32
35
if ($ iterableAtLeastOnce ->no ()) {
33
- return new ConstantArrayType ([], []) ;
36
+ return [ new NeverType (), $ iterableAtLeastOnce ] ;
34
37
}
35
38
36
39
$ iterableValueType = $ arrayType ->getIterableValueType ();
@@ -44,11 +47,20 @@ public function handleAnyArray(Type $arrayType, Type $columnType, ?Type $indexTy
44
47
}
45
48
}
46
49
50
+ return [$ returnValueType , $ iterableAtLeastOnce ];
51
+ }
52
+
53
+ public function handleAnyArray (Type $ arrayType , Type $ columnType , ?Type $ indexType , Scope $ scope ): Type
54
+ {
55
+ [$ returnValueType , $ iterableAtLeastOnce ] = $ this ->getReturnValueType ($ arrayType , $ columnType , $ scope );
56
+
47
57
if ($ returnValueType instanceof NeverType) {
48
58
return new ConstantArrayType ([], []);
49
59
}
50
60
51
61
if ($ indexType !== null ) {
62
+ $ iterableValueType = $ arrayType ->getIterableValueType ();
63
+
52
64
$ type = $ this ->getOffsetOrProperty ($ iterableValueType , $ indexType , $ scope , false );
53
65
if ($ type !== null ) {
54
66
$ returnKeyType = $ type ;
0 commit comments