classGrammarCoverage
final class GrammarCoverage
@visibility public.Observes derivations without influencing generation or consuming randomness.
Type Aliases§
Checkpoint = array{savedAt: string, runId: string, generationsObservedInRun: int, generationInProgress: bool}History = array{formatVersion: int, grammarFingerprint: string, generatorRevision: string, root: string, inventoryDigest: string, cumulative: array{reachedIds: list<string>, emittedIds: list<string>}, checkpoint: Checkpoint}Snapshot = array{formatVersion: int, grammarFingerprint: string, generatorRevision: string, root: string, inventoryDigest: string, denominatorIds: list<string>, inventory: array<string, Entry>, adaptations: list<array{origin: string, status: string}>, current: Measurement, cumulative: Measurement, checkpoint: Checkpoint, restoredCheckpoint: Checkpoint|null}Measurement = import from CoverageSetsTrace = import from GenerationTraceEntry = import from GrammarCoverageInventory$coverage = new \SqlFaker\Generation\Coverage\GrammarCoverage();
$coverage->lastGeneration() // => nullConstants§
public const FLUSH_INTERVAL = 100Number of generations after which unsaved discoveries are written to the snapshot directory.
Methods§
public function __construct(private ?string $storageDirectory = null)Enables memory-only measurement unless a snapshot directory is explicitly supplied.
A supplied directory is written every FLUSH_INTERVAL generations and once more at shutdown, so callers only decide whether coverage is recorded.
Parameters
$storageDirectory | ?string |
public function register(GrammarCoverageInventory $inventory, string $revision): voidRegisters the full inventory and restores compatible history exactly once.
Parameters
$inventory | GrammarCoverageInventory | |
$revision | string |
Throws
CoverageException When already registered to an incompatible generatorTest cases 28
GrammarCoverageTest::testBeginAttemptRetainsAnEmptyAttemptBeforeAnyProductionIsSelectedcallsGrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecallsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscallsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycallsGrammarCoverageTest::testEndGenerationPreservesFailureBeforeAnyAttemptWasOpenedcallsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscallsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescallsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscallsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycallsGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecallsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscallsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycallsGrammarCoverageTest::testMergeRejectsChangedImplementationRevisionscallsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscallsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscallsGrammarCoverageTest::testRecordOutputExposesCandidateAndBoundaryDecisionscallsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecallsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcallsGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycallsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcallsSnapshotValidationTest::providerMalformedHistoriescallsSnapshotValidationTest::testCompatibleRejectsAnUntrustedInventoryDigestcallsSnapshotValidationTest::testCompatibleRejectsEmittedProductionsThatWereNeverReachedcallsSnapshotValidationTest::testCompatibleRejectsUnknownProductionIdscallsSnapshotValidationTest::testCompatibleRequiresEveryIdentityComponentcallsSnapshotValidationTest::testDecodeRestoresOnlyWellFormedSnapshotDatacalls
Calls 3
- new CoverageException line 78
- method-call GrammarCoverage::restore() line 85
- new CoverageSets line 90
public function restore(): voidRestores only after compatibility identity is known; failed setup remains retryable.
Throws
CoverageException When history is corrupt, incompatible or inaccessibleTest cases 1
Called from 1
Calls 6
- method-call GrammarCoverage::inventory() line 106
- function-call
hashline 107 - new CoverageSnapshotStore line 108
- method-call SnapshotValidation::decode() line 111
- new SnapshotValidation line 111
- method-call GrammarCoverage::merge() line 112
public function inventory(): GrammarCoverageInventoryReturns the full denominator, including alternatives never observed.
Returns
Throws
CoverageException When not attached to a providerTest cases 20
GrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecallsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscallsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycallsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscallsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescallsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscallsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycallsGrammarCoverageTest::testInventoryRequiresProviderRegistrationcallsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscallsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycallsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscallsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscallsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycallsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcallsSnapshotValidationTest::testCompatibleRejectsAnUntrustedInventoryDigestcallsSnapshotValidationTest::testCompatibleRejectsEmittedProductionsThatWereNeverReachedcallsSnapshotValidationTest::testCompatibleRejectsUnknownProductionIdscallsSnapshotValidationTest::testCompatibleRequiresEveryIdentityComponentcalls
Called from 4
- method-call SqlFaker\Generation\Coverage\GrammarCoverage::restore() packages/sql-faker/src/Generation/Coverage/GrammarCoverage.php:106
- method-call SqlFaker\Generation\Coverage\GrammarCoverage::recordSequence() packages/sql-faker/src/Generation/Coverage/GrammarCoverage.php:164
- method-call SqlFaker\Generation\Coverage\GrammarCoverage::snapshot() packages/sql-faker/src/Generation/Coverage/GrammarCoverage.php:254
- method-call SqlFaker\Generation\Coverage\GrammarCoverage::merge() packages/sql-faker/src/Generation/Coverage/GrammarCoverage.php:275
Calls 1
public function beginGeneration(
string $root,
array<string, int|string|bool|null> $planSummary,
): voidBegins a generation and replaces even the previous successful trace.
Parameters
$root | string | |
$planSummary | array<string, int|string|bool|null> |
Test cases 19
GrammarCoverageTest::testBeginAttemptRetainsAnEmptyAttemptBeforeAnyProductionIsSelectedcallsGrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecallsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscallsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycallsGrammarCoverageTest::testEndGenerationPreservesFailureBeforeAnyAttemptWasOpenedcallsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscallsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescallsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscallsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscallsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycallsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscallsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscallsGrammarCoverageTest::testRecordOutputExposesCandidateAndBoundaryDecisionscallsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecallsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcallsGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycallsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcalls
Calls 1
public function beginAttempt(int $id): voidBegins one lexical realization attempt.
Parameters
$id | int |
Test cases 17
GrammarCoverageTest::testBeginAttemptRetainsAnEmptyAttemptBeforeAnyProductionIsSelectedcallsGrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecallsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscallsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycallsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscallsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescallsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscallsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycallsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscallsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycallsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscallsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscallsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecallsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcallsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcalls
public function record(
int $node,
?int $parent,
?int $position,
string $rule,
string $production,
string $reason,
): voidRecords an occurrence immediately after production selection.
Parameters
$node | int | |
$parent | ?int | |
$position | ?int | |
$rule | string | |
$production | string | |
$reason | string |
Test cases 15
GrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecallsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscallsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycallsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscallsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescallsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscallsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycallsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscallsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycallsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscallsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscallsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcallsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcalls
public function recordSequence(TerminalSequence $sequence): voidRecords original grammar choices even when a rewrite replaces their entire output.
Parameters
$sequence | TerminalSequence |
Test cases 1
Calls 6
- method-call GrammarCoverage::inventory() line 164
- method-call GrammarCoverage::record() line 167
- function-call
array_valuesline 178 - function-call
array_uniqueline 178 - method-call LexicalObservation::rewrites() line 179
- new LexicalObservation line 179
public function recordOutput(ResolvedOutput $output): voidExposes chosen compound candidates and the boundary rules used in the final output.
Parameters
$output | ResolvedOutput |
Calls 5
- new LexicalObservation line 191
- method-call LexicalObservation::features() line 192
- method-call LexicalObservation::sources() line 193
- method-call LexicalObservation::conditions() line 194
- function-call
array_mapline 196
public function discardAttempt(string $error): voidKeeps failed paths reached without treating them as SQL output.
Parameters
$error | string |
Test cases 12
GrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecallsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscallsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycallsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescallsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscallsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycallsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscallsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycallsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscallsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcalls
public function commitAttempt(string $sqlHash, list<int>|null $nodes = null): voidAdds only preserved source productions from the successful attempt to emitted coverage.
Parameters
$sqlHash | string | |
$nodes | list<int>|null | Preserved occurrence IDs, or null for an unmodified derivation |
Test cases 15
GrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecallsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscallsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycallsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscallsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescallsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscallsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycallsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscallsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycallsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscallsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecallsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcallsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcalls
public function endGeneration(): voidCloses the generation in a finally block, retaining failures, and saves every FLUSH_INTERVAL generations.
Throws
CoverageException When a snapshot cannot be encodedTest cases 16
GrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecallsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscallsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycallsGrammarCoverageTest::testEndGenerationPreservesFailureBeforeAnyAttemptWasOpenedcallsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscallsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescallsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscallsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycallsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscallsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycallsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscallsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecallsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcallsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcalls
Calls 2
- class-const GrammarCoverage::FLUSH_INTERVAL() line 232
- method-call GrammarCoverage::flush() line 233
public function lastGeneration(): Trace|nullReturns the latest generation only; no full-run trace is accumulated.
Returns
Trace|nullTest cases 16
GrammarCoverageTest::testBeginAttemptRetainsAnEmptyAttemptBeforeAnyProductionIsSelectedcallsGrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecallsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscallsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycallsGrammarCoverageTest::testEndGenerationPreservesFailureBeforeAnyAttemptWasOpenedcallsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscallsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycallsGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecallsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscallsGrammarCoverageTest::testRecordOutputExposesCandidateAndBoundaryDecisionscallsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsSqlGeneratorTest::testGenerateClosesCoverageAfterARejectedEmptyLexicalResultcallsSqlGeneratorTest::testGenerateKeepsRewrittenSourcesReachedWithoutCreditingTheirOutputcallsSqlGeneratorTest::testGenerateRecordsACompleteCoverageObservationcallsSqlGeneratorTest::testGenerateReplacesGrammarCoverageWithTheLatestLexicalTracecalls
public function snapshot(): SnapshotReads named current and cumulative sets without performing file I/O.
Returns
Test cases 25
GrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscallsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscallsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescallsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscallsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycallsGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecallsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscallsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycallsGrammarCoverageTest::testMergeRejectsChangedImplementationRevisionscallsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscallsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecallsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycallsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcallsSnapshotValidationTest::providerMalformedHistoriescallsSnapshotValidationTest::testCompatibleRejectsAnUntrustedInventoryDigestcallsSnapshotValidationTest::testCompatibleRejectsEmittedProductionsThatWereNeverReachedcallsSnapshotValidationTest::testCompatibleRejectsUnknownProductionIdscallsSnapshotValidationTest::testCompatibleRequiresEveryIdentityComponentcallsSnapshotValidationTest::testDecodeRestoresOnlyWellFormedSnapshotDatacallsSqlGeneratorTest::testGenerateClosesCoverageAfterARejectedEmptyLexicalResultcallsSqlGeneratorTest::testGenerateKeepsRewrittenSourcesReachedWithoutCreditingTheirOutputcallsSqlGeneratorTest::testGenerateRecordsACompleteCoverageObservationcallsSqlGeneratorTest::testGenerateReplacesGrammarCoverageWithTheLatestLexicalTracecalls
Called from 2
Calls 3
- method-call GrammarCoverage::inventory() line 254
- method-call CoverageSets::measurement() line 261
- function-call
gmdateline 263
public function merge(History $snapshot): voidUnions compatible cumulative history without counting it as current observation.
Parameters
$snapshot | History |
Throws
CoverageException When identity, inventory or saved IDs are invalidTest cases 3
Called from 1
Calls 6
- method-call SnapshotValidation::compatible() line 275
- new SnapshotValidation line 275
- method-call GrammarCoverage::snapshot() line 275
- method-call GrammarCoverage::inventory() line 275
- function-call
array_fill_keysline 276 - function-call
array_diff_keyline 278
public function flush(): voidSaves dirty cumulative sets without clearing this run's observations.
Throws
CoverageException When a snapshot cannot be encodedTest cases 8
GrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescallsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscallsGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecallsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycallsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscallsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcalls
Called from 1
Calls 4
- method-call GrammarCoverage::snapshot() line 295
- function-call
json_encodeline 300 - new CoverageException line 302
- method-call CoverageSets::include() line 305
public function reset(): voidClears current observations only; flush first to retain unsaved discoveries.
Test cases 4
GrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycallsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycalls
Calls 1
- new CoverageSets line 314
Private surface 12§
Implementation details, listed for orientation only.
private ?GrammarCoverageInventory $inventory = nullprivate string $revision = ''private CoverageSets $savedprivate CoverageSets $currentprivate ?GenerationTrace $trace = nullprivate ?CoverageSnapshotStore $store = nullprivate bool $dirty = falseprivate bool $inProgress = falseprivate int $generations = 0private string $runIdprivate Checkpoint|null $restoredCheckpoint = nullprivate ?string $storageDirectory = nullTest cases 37§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 23
GrammarCoverageTest::testBeginAttemptRetainsAnEmptyAttemptBeforeAnyProductionIsSelectedcallsGrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecallsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscallsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycallsGrammarCoverageTest::testEndGenerationPreservesFailureBeforeAnyAttemptWasOpenedcallsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscallsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescallsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscallsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycallsGrammarCoverageTest::testInventoryRequiresProviderRegistrationcallsGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecallsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscallsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycallsGrammarCoverageTest::testMergeRejectsChangedImplementationRevisionscallsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscallsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscallsGrammarCoverageTest::testRecordOutputExposesCandidateAndBoundaryDecisionscallsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecallsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescallsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscallsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcallsGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycallsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcalls
Other tests reaching this symbol 14
ByteChoicesTestcallsCoverageSnapshotStoreTestcallsGrammarCoverageInventoryTestcallsSnapshotValidationTest::providerMalformedHistoriescallsSnapshotValidationTest::testCompatibleRejectsAnUntrustedInventoryDigestcallsSnapshotValidationTest::testCompatibleRejectsEmittedProductionsThatWereNeverReachedcallsSnapshotValidationTest::testCompatibleRejectsUnknownProductionIdscallsSnapshotValidationTest::testCompatibleRequiresEveryIdentityComponentcallsSnapshotValidationTest::testDecodeRestoresOnlyWellFormedSnapshotDatacallsDerivationNodeTestcallsSqlGeneratorTest::testGenerateClosesCoverageAfterARejectedEmptyLexicalResultcallsSqlGeneratorTest::testGenerateKeepsRewrittenSourcesReachedWithoutCreditingTheirOutputcallsSqlGeneratorTest::testGenerateRecordsACompleteCoverageObservationcallsSqlGeneratorTest::testGenerateReplacesGrammarCoverageWithTheLatestLexicalTracecalls
Relations§
Type declarations 7
- type SqlFaker\Generation\SqlGenerator packages/sql-faker/src/Generation/SqlGenerator.php:55
- type SqlFaker\MySql\Generation\SqlGeneratorFactory packages/sql-faker/src/MySql/Generation/SqlGeneratorFactory.php:22
- type SqlFaker\MySql\MySqlProvider packages/sql-faker/src/MySql/MySqlProvider.php:66
- type SqlFaker\PostgreSql\Generation\SqlGeneratorFactory packages/sql-faker/src/PostgreSql/Generation/SqlGeneratorFactory.php:22
- type SqlFaker\PostgreSql\PostgreSqlProvider packages/sql-faker/src/PostgreSql/PostgreSqlProvider.php:53
- type SqlFaker\Sqlite\Generation\SqlGeneratorFactory packages/sql-faker/src/Sqlite/Generation/SqlGeneratorFactory.php:22
- type SqlFaker\Sqlite\SqliteProvider packages/sql-faker/src/Sqlite/SqliteProvider.php:53