File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -548,21 +548,18 @@ public function getVariableType(string $variableName): Type
548548 }
549549 }
550550
551- $ varExprString = '$ ' . $ variableName ;
552- if ($ this ->isGlobalVariable ($ variableName )) {
553- if (array_key_exists ($ varExprString , $ this ->expressionTypes )) {
554- return TypeUtils::resolveLateResolvableTypes ($ this ->expressionTypes [$ varExprString ]->getType ());
555- }
556-
557- return new ArrayType (new BenevolentUnionType ([new IntegerType (), new StringType ()]), new MixedType (true ));
558- }
559-
560551 if ($ this ->hasVariableType ($ variableName )->no ()) {
561552 throw new UndefinedVariableException ($ this , $ variableName );
562553 }
563554
555+ $ defaultType = new MixedType ();
556+ if ($ this ->isGlobalVariable ($ variableName )) {
557+ $ defaultType = new ArrayType (new BenevolentUnionType ([new IntegerType (), new StringType ()]), new MixedType (true ));
558+ }
559+
560+ $ varExprString = '$ ' . $ variableName ;
564561 if (!array_key_exists ($ varExprString , $ this ->expressionTypes )) {
565- return new MixedType () ;
562+ return $ defaultType ;
566563 }
567564
568565 return TypeUtils::resolveLateResolvableTypes ($ this ->expressionTypes [$ varExprString ]->getType ());
You can’t perform that action at this time.
0 commit comments