classSnapshot
final class Snapshot
A coverage snapshot lists every source unit in scope with the semantic fingerprint of the records claiming it, and nothing else: no source text. Comparing the current analysis with the snapshot of a trusted base revision yields the new or changed units, which form the differential denominator, and the units the snapshot lists but the scope no longer contains.
Constants§
public const TYPE = 'requirements-snapshot'The type written in every coverage snapshot.
Methods§
public function create(
Analysis $analysis,
Project $project,
): array{version: int, type: string, units: array<string, array{fingerprint: string}>}Creates the snapshot of an analysis.
Returns
array{version: int, type: string, units: array<string, array{fingerprint: string}>} The snapshot documentThrows
JsonException When a record cannot be encodedTest cases 4
Called from 1
Calls 1
- class-const Snapshot::TYPE() line 41
public function read(string $file): array<string, string>Reads a snapshot file.
Parameters
$file | string | The snapshot file |
Returns
array<string, string> The fingerprints by unit keyThrows
InvalidInputException When the file cannot be read, is not a coverage snapshot or lists an invalid unitJsonException When the file is not JSONTest cases 9
SnapshotTest::testCompareDetectsChangedClaimsNewUnitsAndRemovedScopecallsSnapshotTest::testCreateListsOnlyFingerprintsAndCompareDetectsDriftcallsSnapshotTest::testReadAcceptsASnapshotWithoutUnitscallsSnapshotTest::testReadRejectsACoverageReportcallsSnapshotTest::testReadRejectsAFileThatCannotBeReadcallsSnapshotTest::testReadRejectsAFileThatIsNotJsoncallsSnapshotTest::testReadRejectsAMalformedSnapshotcallsSnapshotTest::testReadRejectsAUnitWithoutFingerprintcallsSnapshotTest::testReadReturnsTheFingerprintsByUnitKeycalls
Called from 1
Calls 8
- function-call
is_fileline 56 - function-call
file_get_contentsline 56 - new InvalidInputException line 58
- static-call Fields::mapping() line 60
- function-call
json_decodeline 60 - class-const Snapshot::TYPE() line 61
- static-call Fields::text() line 67
- function-call
preg_matchline 68
public function compare(
Analysis $analysis,
Project $project,
array<string, string> $snapshot,
): array{changed: list<string>, removed: list<string>}Compares an analysis with a snapshot.
Parameters
Returns
array{changed: list<string>, removed: list<string>} The new or changed unit keys and the unit keys no longer in scopeThrows
JsonException When a record cannot be encodedTest cases 3
Called from 1
Test cases 13§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 11
SnapshotTest::testCompareDetectsChangedClaimsNewUnitsAndRemovedScopecallsSnapshotTest::testCompareListsNewAndChangedUnitsAndRemovedKeyscallsSnapshotTest::testCreateListsOnlyFingerprintsAndCompareDetectsDriftcallsSnapshotTest::testCreateListsTheFingerprintOfEveryUnitcallsSnapshotTest::testReadAcceptsASnapshotWithoutUnitscallsSnapshotTest::testReadRejectsACoverageReportcallsSnapshotTest::testReadRejectsAFileThatCannotBeReadcallsSnapshotTest::testReadRejectsAFileThatIsNotJsoncallsSnapshotTest::testReadRejectsAMalformedSnapshotcallsSnapshotTest::testReadRejectsAUnitWithoutFingerprintcallsSnapshotTest::testReadReturnsTheFingerprintsByUnitKeycalls
Other tests reaching this symbol 2
Relations§
Instantiated in 2
Method calls 3
- method-call Requirements\Console\Executor::execute() packages/requirements/src/Console/Executor.php:60
- method-call Requirements\Report\Coverage::report() packages/requirements/src/Report/Coverage.php:52
- method-call Requirements\Report\Coverage::report() packages/requirements/src/Report/Coverage.php:52