classSource
final class Source
Public API: explicitly declared with
@visibility public.A source document a definition quotes, and the scope of units that coverage counts.
The URI is an HTTP(S) URL or a path relative to the configuration; a pinned snapshot is a local copy verified by its SHA-256 digest. The format names the source extension and the selector declares the coverage scope in that extension's syntax.
$source = new \Requirements\Model\Source('manual', 'https://example.org/manual.html', 'html', 'main p');
[$source->id, $source->format, $source->selector, $source->snapshot] // => ['manual', 'html', 'main p', null]$source = \Requirements\Model\Source::from(['id' => 'notes', 'uri' => 'notes.txt', 'format' => 'text', 'selector' => 'lines:1-3', 'options' => ['encoding' => 'utf-8']]);
[$source->uri, $source->options] // => ['notes.txt', ['encoding' => 'utf-8']]\Requirements\Model\Source::from(['id' => 'manual', 'uri' => 'https://example.org/', 'format' => 'html', 'selector' => 'p', 'snapshot' => 'cache/manual.html']) // throws \Requirements\Input\InvalidInputException: SHA-256Properties§
public string $idpublic string $uripublic string $formatpublic string $selectorpublic string|null $snapshot = nullpublic string|null $sha256 = nullpublic array<string, mixed> $options = []Methods§
public function __construct(
public string $id,
public string $uri,
public string $format,
public string $selector,
public string|null $snapshot = null,
public string|null $sha256 = null,
public array<string, mixed> $options = [],
)Parameters
$id | string | The source identifier used by coverage thresholds and reports |
$uri | string | The HTTP(S) URL or local path of the document |
$format | string | The source extension that reads the document |
$selector | string | The coverage scope in the extension's selector syntax |
$snapshot | string|null | The local copy read instead of the URI unless live |
$sha256 | string|null | The lowercase SHA-256 digest of the document |
$options | array<string, mixed> | Extension-specific options |
public static function from(mixed $value): selfReads the source mapping of a definition.
Parameters
$value | mixed | The decoded source mapping |
Returns
self The sourceThrows
InvalidInputException When fields are unknown or missing, or a snapshot lacks a valid digestTest cases 6
SourceTest::testFromAcceptsADigestWithoutSnapshotcallsSourceTest::testFromReadsSnapshotDigestAndOptionscallsSourceTest::testFromReadsTheRequiredFieldsWithDefaultscallsSourceTest::testFromRejectsInvalidMappingscallsSourceTest::testFromRejectsSnapshotsWithoutAValidDigestcallsSourceTest::testFromTreatsNullSnapshotAndDigestAsAbsentcalls
Called from 2
Calls 6
- static-call Fields::mapping() line 61
- static-call Fields::keys() line 62
- static-call Fields::text() line 63
- function-call
preg_matchline 65 - new InvalidInputException line 66
- new
selfline 68
Test cases 153§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
SourceTest::testFromAcceptsADigestWithoutSnapshotcallsSourceTest::testFromReadsSnapshotDigestAndOptionscallsSourceTest::testFromReadsTheRequiredFieldsWithDefaultscallsSourceTest::testFromRejectsInvalidMappingscallsSourceTest::testFromRejectsSnapshotsWithoutAValidDigestcallsSourceTest::testFromTreatsNullSnapshotAndDigestAsAbsentcalls
Other tests reaching this symbol 147
MemorySourcecallsUnreadableSourcecallsCoverageThresholdsTest::testReadAcceptsBoundscallsCoverageThresholdsTest::testReadAcceptsNoThresholdscallsCoverageThresholdsTest::testReadRejectsInvalidThresholdscallsCoverageThresholdsTest::testReadReturnsThresholdsAsFloatscallsDefinitionReaderTest::testReadReturnsItemsSourcesAndFilescallsDefinitionsTest::testHoldsItemsSourcesAndFilescallsDocumentReaderTestcallsLoaderTest::testLoadReturnsProjectcallsCardReaderTest::testCardReadsBadgesStatementEvidenceAndFieldscallsCardReaderTest::testCardsReadsEveryCardcallsCitationTest::testSelectorDerivesTheSelectorFromTheLinkcallsCitationTest::testSelectorRejectsCitationsThatDoNotIdentifyTheUnitcallsCitationTest::testUrlCreatesTheCitationLinkcallsCitationTest::testValidateAcceptsSelectorsThatIdentifyTheQuotecallsCitationTest::testValidateRejectsATextFragmentThatSelectsOtherTextcallsQuotationBlocksTest::testReadLeavesAParagraphWithMoreThanALinkAfterTheQuotationcallsQuotationBlocksTest::testReadReadsTheLeadingQuotationsAndTheirAttributionscallsQuotationBlocksTest::testReadRejectsAnAttributionWithAnEmptyDestinationcallsQuotationBlocksTest::testReadRejectsTwoSourceCitationscallsQuotationTest::testReadDerivesTheSelectorFromTheAttributioncallsQuotationTest::testReadDerivesTheSelectorFromTheLinkInsideTheQuotationcallsQuotationTest::testReadKeepsASelectorCommentThatTheLinkAgreesWithcallsQuotationTest::testReadReadsASelectorCommentAndTheQuotedTextcallsQuotationTest::testReadRejectsASecondSourceCitationcallsQuotationTest::testReadRejectsMalformedQuotationscallsQuotationTest::testRenderWritesTheQuotationcallsReferenceTestcallsCardWriterTest::testRenderReusesTheLinksBadgesAndCitationsReadcallsMarkdownDocumentTestcallsApplicationTestcallsCommandHandlerTestcallsCommandLineTestcallsExecutorTestcallsFormatterTestcallsItemRecordTest::testDescribeReturnsTheCompleteTraceabilityRecordcallsOptionsTest::testMatchesFiltersASourcedItemcallsItemTest::testFromReadsARequirementQuotingItsSourcecallsItemTest::testFromReadsASpecificationWithDefaultscallsItemTest::testFromRejectsInvalidItemscallsItemValidatorTest::providerDispositionAcceptsItemscallsItemValidatorTest::providerDispositionRejectsItemscallsItemValidatorTest::providerValidateAcceptsItemscallsItemValidatorTest::providerValidateReportsTheFirstBrokenRulecallsProjectTest::testHoldsEveryPartcallsAnalysisTest::testSummaryCountsTheGivenUnitscallsAnalyzerTest::testAnalyzeReadsPinnedSnapshotsUnlessLivecallsClaimsTest::testAssignKeepsOtherSpecificationsWhenOneIsInvalidcallsClaimsTest::testAssignLetsASpecificationClaimTheEvidenceOfTheRequirementsItRefinescallsClaimsTest::testAssignLetsNoRequirementClaimItsOwnEvidencecallsClaimsTest::testAssignOrdersTheUnitsByKeycallsClaimsTest::testAssignRecordsTheEvidenceOfASpecificationcallsClaimsTest::testAssignSkipsASpecificationRefiningARequirementWithInvalidEvidencecallsClaimsTest::testAssignSkipsASpecificationWithInvalidEvidencecallsCoverageTest::testReportAppliesTheDifferentialThresholdToNewAndChangedUnitscallsCoverageTest::testReportAppliesTheOverallThresholdcallsCoverageTest::testReportAppliesTheSourceThresholdscallsCoverageTest::testReportDescribesEveryUnitAndPassesWithoutGatescallsCoverageTest::testReportRejectsRemovedUnitsUnlessAllowedcallsCoverageTest::testReportSkipsTheDifferentialThresholdWithoutChangedUnitscallsEvidenceMatcherTest::testMatchReadsTheSnapshotUnlessLivecallsEvidenceMatcherTest::testMatchRejectsAnUnknownFormatcallsEvidenceMatcherTest::testMatchRejectsAPartialQuotationcallsEvidenceMatcherTest::testMatchRejectsASelectorMatchingNoUnitcallsEvidenceMatcherTest::testMatchRejectsASelectorMatchingSeveralUnitscallsEvidenceMatcherTest::testMatchRejectsAUnitOutsideTheScopecallsEvidenceMatcherTest::testMatchRejectsTheTextOfTheOtherReadingModecallsEvidenceMatcherTest::testMatchReturnsTheKeyOfTheQuotedUnitcallsSnapshotTest::testCompareListsNewAndChangedUnitsAndRemovedKeyscallsSnapshotTest::testCreateListsTheFingerprintOfEveryUnitcallsSourceUnitTest::testFingerprintChangesWithTheRefinedRequirementRecordcallsSourceUnitTest::testFingerprintHashesClaimsAndRefinedRequirementsByIDcallsSourceUnitTest::testFingerprintHashesTheTextWithoutClaimscallsSourceUnitTest::testFingerprintIgnoresTheOrderOfClaimscallsSourceUnitTest::testSupportedIsFalseWithOnlyUnsupportedClaimscallsSourceUnitTest::testSupportedIsFalseWithoutClaimscallsSourceUnitTest::testSupportedIsTrueWhenAnyClaimIsSupportedcallsSourceUnitTest::testToArrayReportsAnUncoveredUnitcallsSourceUnitTest::testToArrayReportsAnUnsupportedUnitcallsSourceUnitTest::testToArrayReportsASupportedUnitcallsUnitCollectorTest::testCollectAcceptsUnitsThatDoNotOverlapcallsUnitCollectorTest::testCollectAddsTheSelectedUnitsByKeycallsUnitCollectorTest::testCollectKeepsTheUnitsAddedBeforeARejectedUnitcallsUnitCollectorTest::testCollectListsARepeatedUnitOncecallsUnitCollectorTest::testCollectRejectsABlankUnitcallsUnitCollectorTest::testCollectRejectsAncestorsAndDescendantsAcrossScopescallsUnitCollectorTest::testCollectRejectsAnEmptyScopecallsUnitCollectorTest::testCollectRejectsConflictingTextOfTheSameUnitcallsUnitCollectorTest::testCollectSharesAUnitBetweenScopesOfTheSameDocumentcallsUnitCollectorTest::testOpenClearsTheUnitKeysOfAReopenedScopecallsUnitCollectorTest::testOpenStartsAScopeWithNoUnitscallsDomSourceTest::testSelectAcceptsHtmlDoctypecallsDomSourceTest::testSelectAcceptsSiblingsSharingALocationPrefixcallsDomSourceTest::testSelectAcceptsSiblingsSharingAnIndexPrefixcallsDomSourceTest::testSelectDirectiveSelectsEveryUnitWithTheTextcallsDomSourceTest::testSelectDirectiveStillRejectsNestedScopescallsDomSourceTest::testSelectExactDirectiveLocatesTheSameUnitAsCssWithoutChangingTheScopecallsDomSourceTest::testSelectLeavesNoXmlErrorsBehindcallsDomSourceTest::testSelectLocatesUnitsByNodePathWithNormalizedTextcallsDomSourceTest::testSelectMarkdownIsRenderedSafelycallsDomSourceTest::testSelectReadsThroughTheGivenLoadercallsDomSourceTest::testSelectRejectsDirectivesBeforeReadingTheSourcecallsDomSourceTest::testSelectRejectsDirectivesOutsideHtmlcallsDomSourceTest::testSelectRejectsDtdAndEntityDeclarationscallsDomSourceTest::testSelectRejectsMalformedXmlcallsDomSourceTest::testSelectRejectsNestedCoverageUnitscallsDomSourceTest::testSelectRestoresInternalXmlErrorHandlingcallsDomSourceTest::testSelectStableDistinctUnitscallsDomSourceTest::testSelectTextDirectivesCannotReplaceTheCoverageScopecallsDomSourceTest::testSelectVerifiesSnapshotHashcallsDomSourceTest::testSelectXmlEntitiesAreRejectedcallsJsonSourceTest::testSelectAcceptsTheNestingLimitcallsJsonSourceTest::testSelectLocatesUnitsByJsonPointercallsJsonSourceTest::testSelectReadsThroughTheGivenLoadercallsJsonSourceTest::testSelectRejectsDocumentsNestedBeyondTheLimitcallsJsonSourceTest::testSelectRejectsInvalidJsoncallsJsonSourceTest::testSelectRejectsUnsupportedJsonPathInsteadOfSilentlySelectingcallsJsonSourceTest::testSelectStableDistinctUnitscallsRegistryTest::testGetSharesOneLoaderAcrossFormatscallsResourceLoaderTest::testReadAcceptsAMatchingDigestcallsResourceLoaderTest::testReadCachesAMissingSnapshotVerbatimcallsResourceLoaderTest::testReadDownloadsAMissingSnapshotOncecallsResourceLoaderTest::testReadHttpContentIsBoundedAndFailuresAreNotRepeatedcallsResourceLoaderTest::testReadHttpContentIsCachedWithinTheCommandcallsResourceLoaderTest::testReadHttpErrorCannotBecomeValidEvidencecallsResourceLoaderTest::testReadLiveModeBypassesPinnedSnapshotAndDetectsCurrentTextcallsResourceLoaderTest::testReadLiveStillVerifiesASourceWithoutSnapshotcallsResourceLoaderTest::testReadMissingSnapshotIsFetchedAndVerifiedBeforeCachingcallsResourceLoaderTest::testReadPrefersAnExistingSnapshotOverTheUricallsResourceLoaderTest::testReadRejectsAChangedSnapshotcallsResourceLoaderTest::testReadRejectsADifferentDigestcallsResourceLoaderTest::testReadRejectsAnUnverifiedDownloadcallsResourceLoaderTest::testReadRejectsOtherSchemescallsResourceLoaderTest::testReadRemoteSnapshotIsNeverCachedLocallycallsResourceLoaderTest::testReadResolvesPathsAgainstTheDirectorycallsResourceLoaderTest::testReadUnverifiedDownloadIsNeverCachedcallsSourceExtensionTest::testSelectReturnsTheUnitsOfTheScopeOrOfAnEvidenceSelectorcallsTextSourceTest::testSelectLocatesNonblankLinescallsTextSourceTest::testSelectReadsThroughTheGivenLoadercallsTextSourceTest::testSelectRejectsMalformedSelectorscallsTextSourceTest::testSelectRejectsRangesOutsideTheSourcecallsTextSourceTest::testSelectStableDistinctUnitscallsUnitTest::testKeyDistinguishesUnitscallsUnitTest::testKeyHashesTheUriFormatAndLocationcallsUnitTest::testKeyIgnoresTheIdSelectorAndTextcallsVerifierTestcalls
Relations§
Instantiated in 1
Static calls 2
Type declarations 13
- type Requirements\Config\Markdown\Citation packages/requirements/src/Config/Markdown/Citation.php:25
- type Requirements\Model\Item packages/requirements/src/Model/Item.php:41
- type Requirements\Model\Item packages/requirements/src/Model/Item.php:66
- type Requirements\Report\EvidenceMatcher packages/requirements/src/Report/EvidenceMatcher.php:40
- type Requirements\Report\SourceUnit packages/requirements/src/Report/SourceUnit.php:26
- type Requirements\Report\UnitCollector packages/requirements/src/Report/UnitCollector.php:34
- type Requirements\Report\UnitCollector packages/requirements/src/Report/UnitCollector.php:47
- type Requirements\Source\DomSource packages/requirements/src/Source/DomSource.php:46
- type Requirements\Source\JsonSource packages/requirements/src/Source/JsonSource.php:41
- type Requirements\Source\ResourceLoader packages/requirements/src/Source/ResourceLoader.php:62
- type Requirements\Source\SourceExtension packages/requirements/src/Source/SourceExtension.php:34
- type Requirements\Source\TextSource packages/requirements/src/Source/TextSource.php:36
- type Requirements\Source\Unit packages/requirements/src/Source/Unit.php:37