final class Relation

One relation as written, with the roles the operator implies.

The sides are kept in the order they were written so that a plan prints back the way it was given. Which end is the parent comes from the operator, not from the order, so a.id < b.a_id and b.a_id > a.id describe the same shape.

A ? next to an end marks that end optional, as it does in DBML: the referencing column may be null, so the row on the other end need not exist.

Properties§

public ColumnRef $left
public ColumnRef $right
public bool $leftOptional = false
public bool $rightOptional = false

Methods§

public function __construct(
    public ColumnRef $left,
    public RelationKind $kind,
    public ColumnRef $right,
    public bool $leftOptional = false,
    public bool $rightOptional = false,
)

Initializes the collaborators and declared state for this object.

Parameters

$leftColumnRef
$kindRelationKind
$rightColumnRef
$leftOptionalbool
$rightOptionalbool
Calls 2
public static function oneToMany(
    string|ColumnRef $parent,
    string|ColumnRef $child,
    bool $childOptional = false,
): self

parent.column < child.column: one parent row, several child rows.

Parameters

$parentstring|ColumnRef
$childstring|ColumnRef
$childOptionalbool

Returns

self
Test cases 27
Called from 1
Calls 3
public function minimumChildRows(): int

The fewest child rows to generate when none are given.

A relation written without ? says the child must be there, so an unspecified child is still generated. Marking it optional is what makes "none at all" a possible outcome.

Returns

int
Called from 1
Calls 1
public function maximumChildRows(): ?int

The most child rows the relation allows, or null where it is unbounded.

Returns

?int
Called from 1
Calls 1
public function childIsOptional(): bool

Whether the child end was marked optional.

This says nothing the data does not already say, since the number of child rows comes from the values supplied for that table.

Returns

bool
Test cases 3
Called from 1
Calls 2
public function tables(): list<string>

Returns

list<string> The tables this relation touches, left end first
Test cases 2

Test cases 70§

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

Dedicated tests 29
Other tests reaching this symbol 41

Relations§

Instantiated in 1
Static calls 3
Method calls 12
Type checks 1
Type declarations 16