Skip to content

Commit 901b335

Browse files
staabmondrejmirtes
authored andcommitted
MutatingScope: Prevent duplicate work in getVariableType()
1 parent 06806d7 commit 901b335

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Analyser/MutatingScope.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,9 @@ public function hasVariableType(string $variableName): TrinaryLogic
675675
/** @api */
676676
public function getVariableType(string $variableName): Type
677677
{
678-
if ($this->hasVariableType($variableName)->maybe()) {
678+
$hasVariableType = $this->hasVariableType($variableName);
679+
680+
if ($hasVariableType->maybe()) {
679681
if ($variableName === 'argc') {
680682
return IntegerRangeType::fromInterval(1, null);
681683
}
@@ -691,7 +693,7 @@ public function getVariableType(string $variableName): Type
691693
}
692694
}
693695

694-
if ($this->hasVariableType($variableName)->no()) {
696+
if ($hasVariableType->no()) {
695697
throw new UndefinedVariableException($this, $variableName);
696698
}
697699

0 commit comments

Comments
 (0)