classShadowSavepoint
final class ShadowSavepoint
Everything a transaction would have to put back, as it was at one moment.
Rolling back is not only about rows: a statement inside a transaction may have created or dropped a table, and a rollback that restored the rows but not what the tables are would leave the shadow describing a database that never existed. Both are taken together, and put back together.
Properties§
public string|null $nameMethods§
public function __construct(
public string|null $name,
private ShadowStore $store,
private TableDefinitionRegistry $registry,
)Binds a savepoint to what it will put back.
Both are taken as they are, which means a caller that means to remember the shadow has to hand over copies of it; of() is what does that.
Parameters
$name | string|null | Name the savepoint was declared under, or null for the transaction itself |
$store | ShadowStore | Rows as they were |
$registry | TableDefinitionRegistry | Tables as they were |
Test cases 6
ShadowSavepointTest::testIsNamedAnswersForTheNameItWasDeclaredUndercoversShadowSavepointTest::testIsNamedIsFalseForTheTransactionItselfcoversShadowSavepointTest::testOfRemembersTheRowsAsTheyWereRatherThanAsTheyBecomecoversShadowSavepointTest::testOfRemembersWhichTablesThereWerecoversShadowSavepointTest::testRestoreIntoLeavesTheTablesAloneWhereNothingIsDescribingThemcoversShadowSavepointTest::testTheNameIsReadableWithoutBeingGuessedAtcovers
public static function of(
string|null $name,
ShadowStore $store,
TableDefinitionRegistry|null $registry,
): selfTakes a savepoint of the shadow as it is now.
Parameters
$name | string|null | Name to declare it under, or null for the transaction itself |
$store | ShadowStore | Rows to remember |
$registry | TableDefinitionRegistry|null | Tables to remember, where anything is describing them |
Returns
self The savepointTest cases 6
ShadowSavepointTest::testIsNamedAnswersForTheNameItWasDeclaredUndercovers and callsShadowSavepointTest::testIsNamedIsFalseForTheTransactionItselfcovers and callsShadowSavepointTest::testOfRemembersTheRowsAsTheyWereRatherThanAsTheyBecomecovers and callsShadowSavepointTest::testOfRemembersWhichTablesThereWerecovers and callsShadowSavepointTest::testRestoreIntoLeavesTheTablesAloneWhereNothingIsDescribingThemcovers and callsShadowSavepointTest::testTheNameIsReadableWithoutBeingGuessedAtcovers and calls
Called from 2
Calls 3
- new
selfline 47 - method-call ShadowStore::snapshot() line 49
- new TableDefinitionRegistry line 50
public function restoreInto(ShadowStore $store, TableDefinitionRegistry|null $registry): voidPuts the shadow back to what it was when the savepoint was taken.
Parameters
$store | ShadowStore | Rows to put back |
$registry | TableDefinitionRegistry|null | Tables to put back, where anything is describing them |
Test cases 3
Calls 1
- method-call ShadowStore::restore() line 62
public function isNamed(string $name): boolReports whether this is the savepoint declared under a name.
Parameters
$name | string | Name to test against |
Returns
bool True when it was declared under that namePrivate surface 2§
Implementation details, listed for orientation only.
private ShadowStore $storeprivate TableDefinitionRegistry $registryTest cases 9§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
ShadowSavepointTest::testIsNamedAnswersForTheNameItWasDeclaredUndercovers and callsShadowSavepointTest::testIsNamedIsFalseForTheTransactionItselfcovers and callsShadowSavepointTest::testOfRemembersTheRowsAsTheyWereRatherThanAsTheyBecomecovers and callsShadowSavepointTest::testOfRemembersWhichTablesThereWerecovers and callsShadowSavepointTest::testRestoreIntoLeavesTheTablesAloneWhereNothingIsDescribingThemcovers and callsShadowSavepointTest::testTheNameIsReadableWithoutBeingGuessedAtcovers and calls
Other tests reaching this symbol 3
SessionTestcallsShadowTransactionsTestcallsTransactionStatementTestcalls