packages/sql-catalog/src/Core/Text/TextHole.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlCatalog\Core\Text;
6
7use Override;
8use SqlCatalog\Core\Type\TypeShape;
9
10/**
11 * A gap where a value the analyzer could not resolve is spliced into a string.
12 *
13 * @visibility root
14 */
15final class TextHole implements TextSegment
16{
17 /**
18 * @param Origin $origin Where the unresolved value comes from
19 * @param TypeShape $type The static type of the spliced value
20 * @param string|null $expression The source expression, when it is short enough to quote
21 * @param string|null $variable The PHP variable read at the use site, when known
22 */
23 public function __construct(
24 public readonly Origin $origin,
25 public readonly TypeShape $type,
26 public readonly ?string $expression = null,
27 public readonly ?string $variable = null,
28 ) {
29 }
30
31 /**
32 * The marker standing in for the unresolved value.
33 */
34 #[Override]
35 public function display(): string
36 {
37 return '{$}';
38 }
39}
40