1: | <?php declare(strict_types = 1); |
2: | |
3: | namespace PHPStan\Node\Printer; |
4: | |
5: | use PhpParser\Node\Expr; |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | class ExprPrinter |
12: | { |
13: | |
14: | public function __construct(private Printer $printer) |
15: | { |
16: | } |
17: | |
18: | public function printExpr(Expr $expr): string |
19: | { |
20: | |
21: | $exprString = $expr->getAttribute('phpstan_cache_printer'); |
22: | if ($exprString === null) { |
23: | $exprString = $this->printer->prettyPrintExpr($expr); |
24: | $expr->setAttribute('phpstan_cache_printer', $exprString); |
25: | } |
26: | |
27: | return $exprString; |
28: | } |
29: | |
30: | } |
31: | |