final class ShadowApplication

Writes one simulated statement into the shadow, all of it or none of it.

A statement that is refused part-way through must leave the shadow as it was, or every later statement is simulated against a state the database would never have been in, so the shadow is taken back to the snapshot before the refusal is passed on.

What comes out through here is a driver-shaped failure. A caller went through an adapter that looks like PDO or mysqli, and a simulation-specific exception surfacing there would be a type it has no reason to know about.

Methods§

public function apply(
    ShadowMutation $mutation,
    ResultSet $resultSet,
    string $sql,
): MutationImpact

Writes a mutation into the shadow and answers what it came to.

Parameters

$mutationShadowMutationMutation to write
$resultSetResultSetWhat the rewritten statement read back
$sqlstringStatement being simulated, for the refusal

Returns

MutationImpact What the statement came to

Throws

DatabaseException When the shadow refuses the statement
Test cases 7
Called from 1
Calls 11
public function lastInsertIdOf(ShadowMutation $mutation, MutationImpact $impact): string|null

Answers the identity a driver would report for a simulated insert.

A table says which column a database numbers; where it says nothing and the key is one column, that column is what a database would have numbered. Only the last row counts, which is what lastInsertId() means.

Parameters

$mutationShadowMutationMutation that was written
$impactMutationImpactWhat it came to

Returns

string|null The identity, or null when nothing was inserted or nothing was numbered
Test cases 4
Called from 1
Calls 8

Private surface 4§

Implementation details, listed for orientation only.

private ShadowStore $shadowStore
private ReferentialIntegrityEnforcer $referentialIntegrity
private TableDefinitionRegistry $registry
private SqlRewriter $rewriter

Test cases 9§

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

Dedicated tests 7
Other tests reaching this symbol 2

Relations§

Instantiated in 1
Method calls 2
Type declarations 1