@@ -4367,29 +4367,24 @@ public function specifyExpressionType(Expr $expr, Type $type, Type $nativeType,
43674367 && !$ expr ->dim instanceof Expr \PostInc
43684368 ) {
43694369 $ dimType = $ scope ->getType ($ expr ->dim )->toArrayKey ();
4370- if ($ dimType-> isInteger ()-> yes () || $ dimType-> isString ()-> yes () ) {
4370+ if ($ dimType instanceof ConstantIntegerType || $ dimType instanceof ConstantStringType ) {
43714371 $ exprVarType = $ scope ->getType ($ expr ->var );
43724372 if (!$ exprVarType instanceof MixedType && !$ exprVarType ->isArray ()->no ()) {
43734373 $ types = [
43744374 new ArrayType (new MixedType (), new MixedType ()),
43754375 new ObjectType (ArrayAccess::class),
43764376 new NullType (),
43774377 ];
4378- if ($ dimType-> isInteger ()-> yes () ) {
4378+ if ($ dimType instanceof ConstantIntegerType ) {
43794379 $ types [] = new StringType ();
43804380 }
4381- $ offsetValueType = TypeCombinator::intersect ($ exprVarType , TypeCombinator::union (...$ types ));
4382-
4383- if ($ dimType instanceof ConstantIntegerType || $ dimType instanceof ConstantStringType) {
4384- $ offsetValueType = TypeCombinator::intersect (
4385- $ offsetValueType ,
4386- new HasOffsetValueType ($ dimType , $ type ),
4387- );
4388- }
43894381
43904382 $ scope = $ scope ->specifyExpressionType (
43914383 $ expr ->var ,
4392- $ offsetValueType ,
4384+ TypeCombinator::intersect (
4385+ TypeCombinator::intersect ($ exprVarType , TypeCombinator::union (...$ types )),
4386+ new HasOffsetValueType ($ dimType , $ type ),
4387+ ),
43934388 $ scope ->getNativeType ($ expr ->var ),
43944389 $ certainty ,
43954390 );
0 commit comments