final class Session
Public API: explicitly declared with @visibility public.

Owns virtual rows, schema, transactions, and connection-local ZTD state.

A session does not reflect a database, rewrite SQL, or execute statements.

Keep fixtures isolated from another sessiondoctest
$first = new \ZtdQuery\Session();
    $second = new \ZtdQuery\Session();
    $first->store()->set('items', [['id' => 1]]);
    $second->store()->get('items') // => []
    $first->isEnabled() // => true

Methods§

public function __construct(
    private ShadowStore $store = new \ZtdQuery\Shadow\ShadowStore(),
    private TableDefinitionRegistry $registry = new \ZtdQuery\Schema\TableDefinitionRegistry(),
    private ViewDefinitionSet $views = new \ZtdQuery\Schema\ViewDefinitionSet(),
)

Start an isolated session, optionally with caller-provided fixtures and schema.

Calls 4
public function rememberInsertId(?string $identity): void

Remember a generated identity, retaining the previous one for other writes.

Parameters

$identity?string
Test cases 2
Called from 1
public function enable(): void

Enable ZTD behavior for this session.

Test cases 1
public function disable(): void
public function transactions(): TransactionTarget

Provides the target used to apply transaction statements to shadow state.

Test cases 1
public function beginTransaction(): void
public function commitTransaction(): void

Keeps the current shadow state and discards transactional snapshots.

Test cases 1
Calls 1
public function applyTransactionStatement(TransactionStatement $statement): void

Applies a parsed transaction statement to this session's shadow state.

Parameters

Test cases 2
Calls 1
public function lastInsertId(): string|false

Answers the identity the last simulated insert would have been given.

Returns

string|false The identity, or false when nothing has been inserted
Test cases 2
public function tableDefinition(string $tableName): TableDefinition|null

Answers what a table was described as, where something described it.

Parameters

$tableNamestringTable to answer for

Returns

TableDefinition|null Its description, or null when nothing has described it
Test cases 3
Called from 1
Calls 1

Private surface 6§

Implementation details, listed for orientation only.

private bool $enabled = true
private ?string $lastInsertId = null
private ShadowTransactions $transactions
private ShadowStore $store = new \ZtdQuery\Shadow\ShadowStore()
private TableDefinitionRegistry $registry = new \ZtdQuery\Schema\TableDefinitionRegistry()
private ViewDefinitionSet $views = new \ZtdQuery\Schema\ViewDefinitionSet()

Test cases 18§

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

Dedicated tests 14
Other tests reaching this symbol 4

Relations§

Instantiated in 1
Method calls 8
Type declarations 3