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 |
Test cases 23
GrammarCoverageTest::testBeginAttemptRetainsAnEmptyAttemptBeforeAnyProductionIsSelectedcoversGrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecoversGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscoversGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycoversGrammarCoverageTest::testEndGenerationPreservesFailureBeforeAnyAttemptWasOpenedcoversGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscoversGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescoversGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscoversGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycoversGrammarCoverageTest::testInventoryRequiresProviderRegistrationcoversGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecoversGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscoversGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycoversGrammarCoverageTest::testMergeRejectsChangedImplementationRevisionscoversGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscoversGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscoversGrammarCoverageTest::testRecordOutputExposesCandidateAndBoundaryDecisionscoversGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecoversGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescoversGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscoversGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcoversGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycoversGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcovers
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::testBeginAttemptRetainsAnEmptyAttemptBeforeAnyProductionIsSelectedcovers and callsGrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecovers and callsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscovers and callsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycovers and callsGrammarCoverageTest::testEndGenerationPreservesFailureBeforeAnyAttemptWasOpenedcovers and callsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscovers and callsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescovers and callsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscovers and callsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycovers and callsGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecovers and callsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscovers and callsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testMergeRejectsChangedImplementationRevisionscovers and callsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscovers and callsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscovers and callsGrammarCoverageTest::testRecordOutputExposesCandidateAndBoundaryDecisionscovers and callsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecovers and callsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcovers and callsGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycovers and callsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcovers and callsSnapshotValidationTest::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 22
GrammarCoverageTest::testBeginAttemptRetainsAnEmptyAttemptBeforeAnyProductionIsSelectedcoversGrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecoversGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscoversGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycoversGrammarCoverageTest::testEndGenerationPreservesFailureBeforeAnyAttemptWasOpenedcoversGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscoversGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescoversGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscoversGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycovers and callsGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecoversGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscoversGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycoversGrammarCoverageTest::testMergeRejectsChangedImplementationRevisionscoversGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscoversGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscoversGrammarCoverageTest::testRecordOutputExposesCandidateAndBoundaryDecisionscoversGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecoversGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescoversGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscoversGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcoversGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycoversGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcovers
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 24
GrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecovers and callsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscovers and callsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycovers and callsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscovers and callsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescovers and callsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscovers and callsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycovers and callsGrammarCoverageTest::testInventoryRequiresProviderRegistrationcovers and callsGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecoversGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscovers and callsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testMergeRejectsChangedImplementationRevisionscoversGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscovers and callsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscovers and callsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecoversGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcoversGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycovers and callsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcovers and callsSnapshotValidationTest::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::testBeginAttemptRetainsAnEmptyAttemptBeforeAnyProductionIsSelectedcovers and callsGrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecovers and callsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscovers and callsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycovers and callsGrammarCoverageTest::testEndGenerationPreservesFailureBeforeAnyAttemptWasOpenedcovers and callsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscovers and callsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescovers and callsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscovers and callsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscovers and callsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscovers and callsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscovers and callsGrammarCoverageTest::testRecordOutputExposesCandidateAndBoundaryDecisionscovers and callsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecovers and callsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcovers and callsGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycovers and callsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcovers and calls
Calls 1
public function beginAttempt(int $id): voidBegins one lexical realization attempt.
Parameters
$id | int |
Test cases 17
GrammarCoverageTest::testBeginAttemptRetainsAnEmptyAttemptBeforeAnyProductionIsSelectedcovers and callsGrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecovers and callsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscovers and callsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycovers and callsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscovers and callsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescovers and callsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscovers and callsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycovers and callsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscovers and callsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscovers and callsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscovers and callsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecovers and callsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcovers and callsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcovers and calls
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 16
GrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecovers and callsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscovers and callsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycovers and callsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscovers and callsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescovers and callsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscovers and callsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycovers and callsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscovers and callsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscovers and callsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscovers and callsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecoversGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcovers and callsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcovers and calls
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 |
Test cases 1
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::testBeginGenerationReplacesThePreviousSuccessfulTracecovers and callsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscovers and callsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycovers and callsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescovers and callsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscovers and callsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycovers and callsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscovers and callsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscovers and callsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcovers and calls
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::testBeginGenerationReplacesThePreviousSuccessfulTracecovers and callsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscovers and callsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycovers and callsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscovers and callsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescovers and callsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscovers and callsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycovers and callsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscovers and callsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscovers and callsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecovers and callsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcovers and callsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcovers and calls
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::testBeginGenerationReplacesThePreviousSuccessfulTracecovers and callsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscovers and callsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycovers and callsGrammarCoverageTest::testEndGenerationPreservesFailureBeforeAnyAttemptWasOpenedcovers and callsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscovers and callsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescovers and callsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscovers and callsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycovers and callsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscovers and callsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscovers and callsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecovers and callsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcovers and callsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcovers and calls
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::testBeginAttemptRetainsAnEmptyAttemptBeforeAnyProductionIsSelectedcovers and callsGrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecovers and callsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscovers and callsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycovers and callsGrammarCoverageTest::testEndGenerationPreservesFailureBeforeAnyAttemptWasOpenedcovers and callsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscovers and callsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycovers and callsGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecovers and callsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscovers and callsGrammarCoverageTest::testRecordOutputExposesCandidateAndBoundaryDecisionscovers and callsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsSqlGeneratorTest::testGenerateClosesCoverageAfterARejectedEmptyLexicalResultcallsSqlGeneratorTest::testGenerateKeepsRewrittenSourcesReachedWithoutCreditingTheirOutputcallsSqlGeneratorTest::testGenerateRecordsACompleteCoverageObservationcallsSqlGeneratorTest::testGenerateReplacesGrammarCoverageWithTheLatestLexicalTracecalls
public function snapshot(): SnapshotReads named current and cumulative sets without performing file I/O.
Returns
Test cases 26
GrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscovers and callsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscovers and callsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescovers and callsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscovers and callsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycovers and callsGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecovers and callsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscovers and callsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testMergeRejectsChangedImplementationRevisionscovers and callsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscovers and callsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecovers and callsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcoversGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycovers and callsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcovers and callsSnapshotValidationTest::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 6
GrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscoversGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescoversGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscoversGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscovers and callsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testMergeRejectsChangedImplementationRevisionscovers and calls
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 10
GrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscoversGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescovers and callsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscovers and callsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycoversGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecovers and callsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscovers and callsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcovers and calls
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::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycovers and calls
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::testBeginAttemptRetainsAnEmptyAttemptBeforeAnyProductionIsSelectedcovers and callsGrammarCoverageTest::testBeginGenerationReplacesThePreviousSuccessfulTracecovers and callsGrammarCoverageTest::testCommitAttemptAndEndGenerationCommitOnlySuccessfulPathscovers and callsGrammarCoverageTest::testDiscardAttemptPreservesFailedReachabilitycovers and callsGrammarCoverageTest::testEndGenerationPreservesFailureBeforeAnyAttemptWasOpenedcovers and callsGrammarCoverageTest::testEndGenerationSavesUnsavedDiscoveriesEveryHundredGenerationscovers and callsGrammarCoverageTest::testFailedReachabilityAndLaterEmissionAreSavedAsSeparateDiscoveriescovers and callsGrammarCoverageTest::testFlushRestoresOnlyCumulativeHistoryAndPreservesCurrentObservationscovers and callsGrammarCoverageTest::testHooksWithoutAGenerationKeepTheTraceEmptycovers and callsGrammarCoverageTest::testInventoryRequiresProviderRegistrationcovers and callsGrammarCoverageTest::testLastGenerationStartsEmptyWithoutStoragecovers and callsGrammarCoverageTest::testMergeIsIdempotentAndDoesNotCopyHistoricalCounterscovers and callsGrammarCoverageTest::testMergePreservesDisjointHistoryAndDoesNotResaveIdenticalHistorycovers and callsGrammarCoverageTest::testMergeRejectsChangedImplementationRevisionscovers and callsGrammarCoverageTest::testReadingAMemorySnapshotDoesNotSaveUnflushedObservationscovers and callsGrammarCoverageTest::testRecordIncludesOccurrenceParentsAndOriginalPositionscovers and callsGrammarCoverageTest::testRecordOutputExposesCandidateAndBoundaryDecisionscovers and callsGrammarCoverageTest::testRecordSequenceKeepsTransformedSelectionsOutOfPreservedOutputCoveragecovers and callsGrammarCoverageTest::testRegisterLeavesOldHistoryWhenTheImplementationChangescovers and callsGrammarCoverageTest::testResetKeepsFlushedHistoryAndClearsTraceAndCurrentCounterscovers and callsGrammarCoverageTest::testRestoreRejectsCorruptHistoryOnEveryRegistrationAttemptWithoutOverwritingItcovers and callsGrammarCoverageTest::testSnapshotPublishesTheRegisteredInventoryAndCurrentRunIdentitycovers and callsGrammarCoverageTest::testSnapshotSeparatesReachedFromEmittedAndKeepsTheFullDenominatorcovers and calls
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\MySqlProvider packages/sql-faker/src/MySqlProvider.php:65
- type SqlFaker\PostgreSqlProvider packages/sql-faker/src/PostgreSqlProvider.php:52
- type SqlFaker\Provider\SqlGeneratorFactory packages/sql-faker/src/Provider/SqlGeneratorFactory.php:25
- type SqlFaker\Provider\SqlGeneratorFactory packages/sql-faker/src/Provider/SqlGeneratorFactory.php:44
- type SqlFaker\Provider\SqlGeneratorFactory packages/sql-faker/src/Provider/SqlGeneratorFactory.php:63
- type SqlFaker\SqliteProvider packages/sql-faker/src/SqliteProvider.php:52