Skip to content

Commit 500fa9c

Browse files
committed
de-duplicate
1 parent 3266a0e commit 500fa9c

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Diff for: src/Analyser/MutatingScope.php

+7-10
Original file line numberDiff line numberDiff 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());

0 commit comments

Comments
 (0)