final class Fields
    implements IteratorAggregate<int, Field>, Countable
    uses Snapshot
Public API: explicitly declared with @visibility public.

The ordered, read-only output fields of a query whose shape is complete.

Order and duplicate names are kept. The collection offers listing, iteration, counting, positional lookup and name lookup, and nothing that adds, removes, reorders or replaces a field.

Looking fields up by position and by namedoctest
$operation = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT 1 AS a, 2 AS a, 3 AS b');
    $fields = $operation->fields();
    [count($fields), $fields->at(2)->name?->value, $fields->lookup('a') instanceof \SqlSemantics\Platform\Sqlite\Model\Statement\Shape\AmbiguousFields] // => [3, 'b', true]

Properties§

public list<Field> $items
public Comparison $names

Methods§

public function __construct(list<Field> $items, public Comparison $names)

Parameters

$itemslist<Field>The fields in output order
$namesComparisonHow output names are compared
Calls 3
public function count(): int

Counts the output positions.

Returns

int
Test cases 1
Calls 1
public function getIterator(): ArrayIterator<int, Field>

Iterates the fields in output order.

Returns

ArrayIterator<int, Field>
Calls 1
public function at(int $position): Field

Answers the field at a zero-based output position.

Parameters

$positionint

Returns

Test cases 2
Calls 1
public function lookup(string $name): UniqueField|AbsentField|AmbiguousFields|DependentField

Finds the fields a name denotes, distinguishing one, none and several.

When a field's name depends on missing inputs, no lookup is decided: the known matches are candidates of a dependent lookup.

Parameters

$namestring
Test cases 3
Calls 7

Test cases 8§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 8

Relations§

Instantiated in 1
Type declarations 2