classEntryFactory
final class EntryFactory
Turns the statements found while walking a file into catalog entries.
Methods§
public function __construct(
?StatementKindReader $kinds = null,
?TableReader $tables = null,
?PlaceholderScanner $placeholders = null,
?EntryIdentity $identity = null,
)Wires the factory to the readers that describe a statement.
Parameters
$kinds | ?StatementKindReader | |
$tables | ?TableReader | |
$placeholders | ?PlaceholderScanner | |
$identity | ?EntryIdentity |
Calls 4
public function build(list<QueryRecord> $records): list<CatalogEntry>The catalog entries the records describe, without the ones a better record supersedes.
Parameters
$records | list<QueryRecord> |
Returns
list<CatalogEntry>Test cases 10
EntryFactoryTest::testBuildGivesTwoIndistinguishableStatementsDistinctIdentifierscallsEntryFactoryTest::testBuildKeepsAnUndeterminedReadingBesideAResolvedOnecallsEntryFactoryTest::testBuildKeepsBothReadingsOfTheSameCallcallsEntryFactoryTest::testBuildNamesALoneStatementAsItsOwnReadingWouldcallsEntryFactoryTest::testBuildNumbersEachFurtherTwinOnceMorecallsEntryFactoryTest::testBuildOfNothingIsEmptycallsEntryFactoryTest::testBuildReportsAStatementBoundWithTheWrongNumberOfValuescallsEntryFactoryTest::testBuildSharesSearchCompletionAcrossEveryCandidatecallsEntryFactoryTest::testBuildTurnsRecordsIntoEntriescallsEntryFactoryTest::testCountMismatchStaysQuietWhenTheCallSiteHasAlternativescalls
Called from 1
Calls 6
- method-call EntryFactory::groupBySite() line 63
- method-call EntryFactory::merge() line 63
- static-call Resolution::of() line 66
- method-call EntryFactory::buildOne() line 69
- function-call
countline 69 - method-call EntryFactory::renumber() line 72
public function renumber(
CatalogEntry $entry,
QueryRecord $record,
int $occurrence,
): CatalogEntryThe same statement under an identifier that tells it apart from its twin.
Parameters
$entry | CatalogEntry | |
$record | QueryRecord | |
$occurrence | int |
Returns
Test cases 2
Called from 1
Calls 2
- new CatalogEntry line 84
- method-call EntryIdentity::compute() line 85
public function merge(list<QueryRecord> $records): list<QueryRecord>The records with every reading of the same statement folded into one.
Parameters
$records | list<QueryRecord> |
Returns
list<QueryRecord>Test cases 2
Called from 1
Calls 1
- function-call
array_valuesline 118
public function groupBySite(list<QueryRecord> $records): array<string, list<QueryRecord>>The records of each call site, keyed by the site.
Parameters
$records | list<QueryRecord> |
Returns
array<string, list<QueryRecord>>Test cases 1
Called from 1
public function buildOne(
QueryRecord $record,
bool $alternatives = false,
bool $siteClosed = true,
): CatalogEntryThe catalog entry one record describes.
Parameters
$record | QueryRecord | |
$alternatives | bool | Whether the call site produced more than one statement |
$siteClosed | bool |
Returns
Test cases 7
EntryFactoryTest::testBuildNamesALoneStatementAsItsOwnReadingWouldcallsEntryFactoryTest::testBuildNumbersEachFurtherTwinOnceMorecallsEntryFactoryTest::testBuildOneCarriesTheCallsThatWereFollowedcallsEntryFactoryTest::testBuildOneReadsTheStatementKindTheCallImpliescallsEntryFactoryTest::testBuildOneRecordsWhetherTheAlternativesAreOnesTheCodeCanReachcallsEntryFactoryTest::testBuildOneReportsAStatementBoundWithTheWrongNumberOfValuescallsEntryFactoryTest::testRenumberKeepsEverythingButTheIdentifiercalls
Called from 1
Calls 7
- method-call EntryFactory::bindPlaceholders() line 145
- new CatalogEntry line 147
- method-call EntryIdentity::compute() line 148
- method-call StatementKindReader::read() line 149
- method-call TableReader::read() line 151
- method-call EntryFactory::findings() line 154
- method-call QueryRecord::isTruncated() line 157
public function bindPlaceholders(TextPattern $pattern, QueryRecord $record): list<Placeholder>The statement's parameters, each carrying whatever was bound to it.
Parameters
$pattern | TextPattern | |
$record | QueryRecord |
Returns
list<Placeholder>Test cases 5
EntryFactoryTest::testBindPlaceholdersLeavesAPlaceholderNothingWasBoundToEmptycallsEntryFactoryTest::testBindPlaceholdersLinesValuesUpByNamecallsEntryFactoryTest::testBindPlaceholdersLinesValuesUpByPositioncallsEntryFactoryTest::testBindPlaceholdersPrefersAValueBoundUnderTheNumberAsANamecallsEntryFactoryTest::testBindPlaceholdersReadsANumberedPlaceholderByPositioncalls
Called from 1
Calls 6
- method-call QueryRecord::positional() line 169
- method-call QueryRecord::named() line 170
- method-call PlaceholderScanner::scan() line 174
- method-call EntryFactory::numberedValue() line 177
- new Placeholder line 178
- static-call ValueDomain::fromDomain() line 182
public function findings(
TextPattern $pattern,
QueryRecord $record,
list<Placeholder> $placeholders,
bool $alternatives = false,
): list<Finding>What is worth reporting about a statement.
Parameters
$pattern | TextPattern | |
$record | QueryRecord | |
$placeholders | list<Placeholder> | |
$alternatives | bool | Whether the call site produced more than one statement |
Returns
list<Finding>Test cases 11
EntryFactoryTest::testFindingsAreEmptyForAResolvedStatementcallsEntryFactoryTest::testFindingsNeverCallAFullyResolvedStatementUnresolvedcallsEntryFactoryTest::testFindingsReportACallNotAnalyzedWithoutClaimingALimitCutItShortcallsEntryFactoryTest::testFindingsReportADynamicStatementcallsEntryFactoryTest::testFindingsReportAnIncompleteSearchOnceEvenWhenALimitAlsoCutItShortcallsEntryFactoryTest::testFindingsReportAReadingALimitCutShortAlongsideAWrongCountcallsEntryFactoryTest::testFindingsReportAStatementBoundWithTheWrongNumberOfValuescallsEntryFactoryTest::testFindingsReportAStatementThatDidNotResolveAtAllcallsEntryFactoryTest::testFindingsReportExternalInputcallsEntryFactoryTest::testFindingsReportExternalInputOnceHoweverManyValuesCarryItcallsEntryFactoryTest::testFindingsReportThatTheSearchDidNotClosecalls
Called from 1
Calls 19
- method-call TextPattern::holes() line 217
- static-call Resolution::of() line 218
- class-const Resolution::NotAnalyzed() line 220
- method-call StatementKindReader::read() line 220
- class-const StatementKind::Unknown() line 220
- static-call Finding::of() line 221
- class-const FindingRule::UnresolvedSql() line 221
- class-const FindingRule::DynamicSql() line 225
- function-call
sprintfline 226 - function-call
countline 226 - class-const Origin::External() line 230
- class-const FindingRule::ExternalInput() line 232
- class-const Resolution::Incomplete() line 239
- class-const FindingRule::AnalysisIncomplete() line 241
- class-const FindingRule::CallNotAnalyzed() line 246
- method-call EntryFactory::notAnalyzedReason() line 246
- method-call QueryRecord::isTruncated() line 248
- method-call EntryFactory::countMismatch() line 255
- function-call
array_mergeline 257
public function notAnalyzedReason(QueryRecord $record): stringWhy no statement was read from a call that is written the way a database call is.
Parameters
$record | QueryRecord |
Returns
stringTest cases 2
Called from 1
Calls 1
- class-const CallSite::UNMATCHED() line 268
public function countMismatch(QueryRecord $record, list<Placeholder> $placeholders): ?FindingThe finding for a statement that binds a different number of values than it takes.
The count is only asserted for a call site that resolved to exactly one statement. Where the analyzer had to enumerate alternatives, one of them having a different number of placeholders is the enumeration talking, not the code.
Parameters
$record | QueryRecord | |
$placeholders | list<Placeholder> |
Returns
Test cases 4
EntryFactoryTest::testCountMismatchCountsValuesBoundByPositionAndByNamecallsEntryFactoryTest::testCountMismatchReportsAStatementBoundWithTheWrongNumberOfValuescallsEntryFactoryTest::testCountMismatchStaysQuietWhenNothingWasBoundcallsEntryFactoryTest::testCountMismatchStaysQuietWhenTheCountsAgreecalls
Called from 1
Calls 7
- method-call QueryRecord::isBound() line 285
- function-call
countline 288 - method-call QueryRecord::positional() line 289
- method-call QueryRecord::named() line 289
- static-call Finding::of() line 294
- class-const FindingRule::PlaceholderCountMismatch() line 295
- function-call
sprintfline 296
Private surface 4§
Implementation details, listed for orientation only.
private StatementKindReader $kindsprivate TableReader $tablesprivate PlaceholderScanner $placeholdersprivate EntryIdentity $identityTest cases 48§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 42
EntryFactoryTest::testBindPlaceholdersLeavesAPlaceholderNothingWasBoundToEmptycallsEntryFactoryTest::testBindPlaceholdersLinesValuesUpByNamecallsEntryFactoryTest::testBindPlaceholdersLinesValuesUpByPositioncallsEntryFactoryTest::testBindPlaceholdersPrefersAValueBoundUnderTheNumberAsANamecallsEntryFactoryTest::testBindPlaceholdersReadsANumberedPlaceholderByPositioncallsEntryFactoryTest::testBuildGivesTwoIndistinguishableStatementsDistinctIdentifierscallsEntryFactoryTest::testBuildKeepsAnUndeterminedReadingBesideAResolvedOnecallsEntryFactoryTest::testBuildKeepsBothReadingsOfTheSameCallcallsEntryFactoryTest::testBuildNamesALoneStatementAsItsOwnReadingWouldcallsEntryFactoryTest::testBuildNumbersEachFurtherTwinOnceMorecallsEntryFactoryTest::testBuildOfNothingIsEmptycallsEntryFactoryTest::testBuildOneCarriesTheCallsThatWereFollowedcallsEntryFactoryTest::testBuildOneReadsTheStatementKindTheCallImpliescallsEntryFactoryTest::testBuildOneRecordsWhetherTheAlternativesAreOnesTheCodeCanReachcallsEntryFactoryTest::testBuildOneReportsAStatementBoundWithTheWrongNumberOfValuescallsEntryFactoryTest::testBuildReportsAStatementBoundWithTheWrongNumberOfValuescallsEntryFactoryTest::testBuildSharesSearchCompletionAcrossEveryCandidatecallsEntryFactoryTest::testBuildTurnsRecordsIntoEntriescallsEntryFactoryTest::testCountMismatchCountsValuesBoundByPositionAndByNamecallsEntryFactoryTest::testCountMismatchReportsAStatementBoundWithTheWrongNumberOfValuescallsEntryFactoryTest::testCountMismatchStaysQuietWhenNothingWasBoundcallsEntryFactoryTest::testCountMismatchStaysQuietWhenTheCallSiteHasAlternativescallsEntryFactoryTest::testCountMismatchStaysQuietWhenTheCountsAgreecallsEntryFactoryTest::testFindingsAreEmptyForAResolvedStatementcallsEntryFactoryTest::testFindingsNeverCallAFullyResolvedStatementUnresolvedcallsEntryFactoryTest::testFindingsReportACallNotAnalyzedWithoutClaimingALimitCutItShortcallsEntryFactoryTest::testFindingsReportADynamicStatementcallsEntryFactoryTest::testFindingsReportAnIncompleteSearchOnceEvenWhenALimitAlsoCutItShortcallsEntryFactoryTest::testFindingsReportAReadingALimitCutShortAlongsideAWrongCountcallsEntryFactoryTest::testFindingsReportAStatementBoundWithTheWrongNumberOfValuescallsEntryFactoryTest::testFindingsReportAStatementThatDidNotResolveAtAllcallsEntryFactoryTest::testFindingsReportExternalInputcallsEntryFactoryTest::testFindingsReportExternalInputOnceHoweverManyValuesCarryItcallsEntryFactoryTest::testFindingsReportThatTheSearchDidNotClosecallsEntryFactoryTest::testGroupBySiteKeepsTheCallsApartcallsEntryFactoryTest::testMergeFoldsTwoReadingsOfTheSameStatementcallsEntryFactoryTest::testMergeKeepsTwoStatementsApartWhenTheirKeyAndTextRunTogethercallsEntryFactoryTest::testNotAnalyzedReasonSaysTheAnalysisStoppedBeforeReadingTheCallcallsEntryFactoryTest::testNotAnalyzedReasonSaysTheReceiverCouldNotBeIdentifiedcallsEntryFactoryTest::testNumberedValueIgnoresANameThatOnlyStartsWithDigitscallsEntryFactoryTest::testNumberedValueReadsAPositionalValueByItsNumbercallsEntryFactoryTest::testRenumberKeepsEverythingButTheIdentifiercalls
Other tests reaching this symbol 6
CatalogCommandTestcallsExpressionEvaluatorTestcallsCallModelTestcallsAnalyzerTestcallsJsonReporterTestcallsTextReporterTestcalls