Skip to content

Commit

Permalink
Don't re-calculate node-key over and over again - part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored and ondrejmirtes committed Dec 10, 2022
1 parent d00f0de commit 3c3b17f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ public function getType(Expr $node): Type
$key = $this->getNodeKey($node);

if (!array_key_exists($key, $this->resolvedTypes)) {
$this->resolvedTypes[$key] = TypeUtils::resolveLateResolvableTypes($this->resolveType($node));
$this->resolvedTypes[$key] = TypeUtils::resolveLateResolvableTypes($this->resolveType($key, $node));
}
return $this->resolvedTypes[$key];
}
Expand All @@ -662,13 +662,12 @@ private function getNodeKey(Expr $node): string
return $key;
}

private function resolveType(Expr $node): Type
private function resolveType(string $exprString, Expr $node): Type
{
if ($node instanceof Expr\Exit_ || $node instanceof Expr\Throw_) {
return new NeverType(true);
}

$exprString = $this->getNodeKey($node);
if (!$node instanceof Variable && $this->hasExpressionType($node)->yes()) {
return $this->expressionTypes[$exprString]->getType();
}
Expand Down

0 comments on commit 3c3b17f

Please sign in to comment.