File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -458,14 +458,24 @@ public function getOffsetValueType(Type $offsetType): Type
458458 {
459459 $ offsetType = ArrayType::castToArrayKeyType ($ offsetType );
460460 $ matchingValueTypes = [];
461+ $ all = true ;
461462 foreach ($ this ->keyTypes as $ i => $ keyType ) {
462463 if ($ keyType ->isSuperTypeOf ($ offsetType )->no ()) {
464+ $ all = false ;
463465 continue ;
464466 }
465467
466468 $ matchingValueTypes [] = $ this ->valueTypes [$ i ];
467469 }
468470
471+ if ($ all ) {
472+ if (count ($ this ->keyTypes ) === 0 ) {
473+ return new ErrorType ();
474+ }
475+
476+ return $ this ->getIterableValueType ();
477+ }
478+
469479 if (count ($ matchingValueTypes ) > 0 ) {
470480 $ type = TypeCombinator::union (...$ matchingValueTypes );
471481 if ($ type instanceof ErrorType) {
You can’t perform that action at this time.
0 commit comments