final class ReferentialIntegrityEnforcer

Carries what a statement did outward through the constraints that declare it.

A write to a parent table does not stop at that table: a key declared ON DELETE CASCADE takes the children with it, and those children may themselves be parents. What happened is therefore followed outward until nothing more follows, and only then is the result checked for the references it has left dangling.

Type Aliases§

Row = import from TableDefinition

Methods§

public function __construct(private TableDefinitionRegistry $registry)

Parameters

$registryTableDefinitionRegistryAnswers what a table declares
Test cases 28
public function synchronize(
    ShadowStore $before,
    ShadowStore $after,
    ShadowMutation $mutation,
    array<int, Row> $resultRows,
    string $sql,
): void

Applies every consequence of a statement, and refuses one it cannot.

Parameters

$beforeShadowStoreShadow as it was
$afterShadowStoreShadow as it became, written back in place
$mutationShadowMutationStatement that was simulated
$resultRowsarray<int, Row>Rows the rewritten statement read back
$sqlstringStatement being simulated, for the refusal

Throws

ForeignKeyViolationException When a constraint forbids the statement or is left broken
Test cases 30
Called from 1
Calls 10

Private surface 1§

Implementation details, listed for orientation only.

private TableDefinitionRegistry $registry

Test cases 39§

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

Dedicated tests 28
Other tests reaching this symbol 11

Relations§

Instantiated in 1
Method calls 1
Type declarations 1