Skip to content

Commit faadcf4

Browse files
lookymanondrejmirtes
authored andcommitted
Cache pretty printed expression
1 parent 13fb5b1 commit faadcf4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Analyser/MutatingScope.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,13 @@ public function getAnonymousFunctionReturnType(): ?\PHPStan\Type\Type
378378

379379
public function getType(Expr $node): Type
380380
{
381-
$key = $this->printer->prettyPrintExpr($node);
381+
/** @var string|null $key */
382+
$key = $node->getAttribute('phpstan_cache_printer');
383+
if ($key === null) {
384+
$key = $this->printer->prettyPrintExpr($node);
385+
$node->setAttribute('phpstan_cache_printer', $key);
386+
}
387+
382388
if (!array_key_exists($key, $this->resolvedTypes)) {
383389
$this->resolvedTypes[$key] = $this->resolveType($node);
384390
}

0 commit comments

Comments
 (0)