@@ -1857,7 +1857,10 @@ private function getTypeFromArrayDimFetch(
18571857 return $ offsetAccessibleType ;
18581858 }
18591859
1860- if (!$ offsetAccessibleType ->isArray ()->yes () && (new ObjectType (ArrayAccess::class))->isSuperTypeOf ($ offsetAccessibleType )->yes ()) {
1860+ if (
1861+ !$ offsetAccessibleType ->isArray ()->yes ()
1862+ && (new ObjectType (ArrayAccess::class))->isSuperTypeOf ($ offsetAccessibleType )->yes ()
1863+ ) {
18611864 return $ this ->getType (
18621865 new MethodCall (
18631866 $ arrayDimFetch ->var ,
@@ -3368,11 +3371,15 @@ public function specifyExpressionType(Expr $expr, Type $type, Type $nativeType,
33683371 $ dimType = $ scope ->getType ($ expr ->dim )->toArrayKey ();
33693372 if ($ dimType ->isInteger ()->yes () || $ dimType ->isString ()->yes ()) {
33703373 $ exprVarType = $ scope ->getType ($ expr ->var );
3371- if (!$ exprVarType instanceof MixedType && !$ exprVarType ->isArray ()->no ()) {
3372- if ($ dimType ->isInteger ()->yes ()) {
3373- $ varType = TypeCombinator::intersect ($ exprVarType , StaticTypeFactory::intOffsetAccessibleType ());
3374- } else {
3375- $ varType = TypeCombinator::intersect ($ exprVarType , StaticTypeFactory::generalOffsetAccessibleType ());
3374+ $ isArray = $ exprVarType ->isArray ();
3375+ if (!$ exprVarType instanceof MixedType && !$ isArray ->no ()) {
3376+ $ varType = $ exprVarType ;
3377+ if (!$ isArray ->yes ()) {
3378+ if ($ dimType ->isInteger ()->yes ()) {
3379+ $ varType = TypeCombinator::intersect ($ exprVarType , StaticTypeFactory::intOffsetAccessibleType ());
3380+ } else {
3381+ $ varType = TypeCombinator::intersect ($ exprVarType , StaticTypeFactory::generalOffsetAccessibleType ());
3382+ }
33763383 }
33773384
33783385 if ($ dimType instanceof ConstantIntegerType || $ dimType instanceof ConstantStringType) {
0 commit comments