packages/sql-semantics-postgres/src/Model/Statement/Shape/OpenStar.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Platform\PostgreSql\Model\Statement\Shape;
6
7use SqlSemantics\Platform\PostgreSql\Model\Diagnostic\Check;
8use SqlSemantics\Platform\PostgreSql\Model\Statement\Reference\Missing\MissingInput;
9use SqlSemantics\Platform\PostgreSql\Model\Statement\Snapshot;
10
11/**
12 * A star projection that cannot be expanded because member lists are missing from the context.
13 *
14 * It stands for an undetermined number of output positions. No placeholder
15 * fields are invented for them.
16 *
17 * @visibility public
18 * @example Keeping an unexpandable star as a typed request
19 * $operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT * FROM t');
20 * $operation->facts->output?->projection[0] instanceof \SqlSemantics\Platform\PostgreSql\Model\Statement\Shape\OpenStar // => true
21 */
22final class OpenStar
23{
24 use Snapshot;
25
26 /**
27 * @var non-empty-list<MissingInput> The member lists needed to expand the star
28 */
29 public readonly array $missing;
30
31 /**
32 * @param list<MissingInput> $missing The member lists needed to expand the star; at least one
33 */
34 public function __construct(array $missing)
35 {
36 $this->missing = Check::listOf($missing, MissingInput::class, 'An open star names at least one missing input.', 1);
37 }
38}
39