File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1004,17 +1004,14 @@ private function doGetOffsetValueType(Type $offsetType): Type
10041004
10051005 if ($ this ->isCallable ()->yes () && $ this ->isArray ()->yes ()) {
10061006 $ arrayKeyOffsetType = $ offsetType ->toArrayKey ();
1007- $ callableArrayOffsetType = new UnionType ([new ConstantIntegerType (0 ), new ConstantIntegerType (1 )]);
1008- if ($ callableArrayOffsetType ->isSuperTypeOf ($ arrayKeyOffsetType )->yes ()) {
1009- if ((new ConstantIntegerType (0 ))->isSuperTypeOf ($ arrayKeyOffsetType )->yes ()) {
1010- $ narrowedType = new UnionType ([new ClassStringType (), new ObjectWithoutClassType ()]);
1011- } elseif ((new ConstantIntegerType (1 ))->isSuperTypeOf ($ arrayKeyOffsetType )->yes ()) {
1012- $ narrowedType = new IntersectionType ([new StringType (), new AccessoryNonFalsyStringType ()]);
1013- } else {
1014- $ narrowedType = new UnionType ([new IntersectionType ([new StringType (), new AccessoryNonFalsyStringType ()]), new ObjectWithoutClassType ()]);
1015- }
1016- $ result = TypeCombinator::intersect ($ result , $ narrowedType );
1007+ if ((new ConstantIntegerType (0 ))->isSuperTypeOf ($ arrayKeyOffsetType )->yes ()) {
1008+ $ narrowedType = new UnionType ([new ClassStringType (), new ObjectWithoutClassType ()]);
1009+ } elseif ((new ConstantIntegerType (1 ))->isSuperTypeOf ($ arrayKeyOffsetType )->yes ()) {
1010+ $ narrowedType = new IntersectionType ([new StringType (), new AccessoryNonFalsyStringType ()]);
1011+ } else {
1012+ $ narrowedType = new UnionType ([new IntersectionType ([new StringType (), new AccessoryNonFalsyStringType ()]), new ObjectWithoutClassType ()]);
10171013 }
1014+ $ result = TypeCombinator::intersect ($ result , $ narrowedType );
10181015 }
10191016
10201017 return $ result ;
You can’t perform that action at this time.
0 commit comments