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