classSinkFinder
final class SinkFinder
Finds every call that is written the way a database call is written.
Reading a statement and finding the call that carries it are separate jobs. A call whose statement cannot be reconstructed is still a place the program talks to a database, and a call nothing could be read from is a gap in the analysis rather than an absence in the program. This pass answers the second question on its own, so neither can be lost to a failure of the first.
Methods§
public function __construct()Builds a finder over the node search.
Calls 1
- new
NodeFinderline 34
public function find(ParsedFile $file, list<SinkSpec> $sinks): list<CallLike>The calls in a file that are written the way a statement-carrying call is written.
Parameters
$file | ParsedFile | |
$sinks | list<SinkSpec> |
Returns
list<CallLike>Test cases 4
Calls 2
- method-call SinkFinder::findIn() line 45
- method-call SinkFinder::namesOf() line 45
public function findAll(ParsedFile $file, list<SinkSpec> $sinks): list<CallLike>The calls in a file written the way any database call is written, including those that only bind values.
Calls that compose a statement are left out: they hand the statement back rather than sending it, so they are read as part of whatever call does.
Parameters
$file | ParsedFile | |
$sinks | list<SinkSpec> |
Returns
list<CallLike>Test cases 3
Called from 1
Calls 4
- class-const SinkRole::Compose() line 61
- function-call
strtolowerline 62 - function-call
ltrimline 62 - method-call SinkFinder::findIn() line 66
public function findIn(
array<array-key, Node> $nodes,
array<string, true> $names,
): list<CallLike>The calls among the given nodes that are written the way a statement-carrying call is written.
Parameters
$nodes | array<array-key, Node> | |
$names | array<string, true> |
Returns
list<CallLike>Test cases 1
Called from 2
Calls 4
- method-call
NodeFinder::findInstanceOf()line 80 - class-const
CallLike::class()line 80 - method-call SinkFinder::nameOf() line 82
- function-call
strtolowerline 83
public function namesOf(list<SinkSpec> $sinks): array<string, true>The names the statement-carrying calls are written with.
Parameters
$sinks | list<SinkSpec> |
Returns
array<string, true>Test cases 2
Called from 1
Calls 5
- class-const SinkRole::Query() line 101
- class-const SinkRole::Prepare() line 101
- class-const SinkRole::Modelled() line 101
- function-call
strtolowerline 102 - function-call
ltrimline 102
public function nameOf(CallLike $call): ?stringThe name a call is written with, or null when it is not written as a name.
Parameters
$call | CallLike |
Returns
?stringTest cases 3
Called from 4
- method-call SqlCatalog\Core\Analysis\Interpreter::sinkOf() packages/sql-catalog/src/Core/Analysis/Interpreter.php:248
- method-call SqlCatalog\Core\Analysis\Interpreter::unidentified() packages/sql-catalog/src/Core/Analysis/Interpreter.php:295
- method-call SqlCatalog\Core\Analysis\SinkFinder::findIn() packages/sql-catalog/src/Core/Analysis/SinkFinder.php:82
- method-call SqlCatalog\Extension\Laravel\BuilderQueries::statements() packages/sql-catalog/src/Extension/Laravel/BuilderQueries.php:51
public function enclosingBody(Node $node): ?FunctionLikeThe function body a node is written inside, or null when it is written outside any.
Parameters
$node | Node |
Returns
?FunctionLikeTest cases 1
Calls 1
- method-call
Node::getAttribute()line 132
Private surface 1§
Implementation details, listed for orientation only.
private NodeFinder $finderTest cases 35§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 11
SinkFinderTest::testEnclosingBodyFindsTheFunctionACallIsWrittenIncallsSinkFinderTest::testFindAllCollectsEveryDatabaseCallButTheOnesThatComposeAStatementcallsSinkFinderTest::testFindAllFindsNothingWhenEverySinkComposesAStatementcallsSinkFinderTest::testFindAllTakesInTheCallsThatOnlyBindValuescallsSinkFinderTest::testFindCollectsTheCallsWrittenLikeDatabaseCallscallsSinkFinderTest::testFindIgnoresACallWrittenWithoutANamecallsSinkFinderTest::testFindInLooksAtTheNodesItIsGivencallsSinkFinderTest::testNameOfIgnoresAStaticCallWrittenWithoutANamecallsSinkFinderTest::testNameOfReadsEveryFormOfCallcallsSinkFinderTest::testNamesOfKeepsOnlyTheCallsThatCarryAStatementcallsSinkFinderTest::testNamesOfWritesEachNameInLowerCaseWithoutALeadingBackslashcalls
Other tests reaching this symbol 24
CatalogCommandTestcallsCallEvaluatorTestcallsConstantReaderTestcallsCalleeReturnsTestcallsCallersTestcallsDeriverTestcallsEntryBinderTestcallsCallbackEffectsTestcallsPropertyWritesTestcallsSliceExecutorTestcallsExpressionEvaluatorTestcallsRegistryTestcallsInterpreterTestcallsModelQueriesTestcallsReferenceEvaluatorTestcallsCallContextTestcallsQueryModelInterfaceTestcallsBuilderCallsTestcallsBuilderQueriesTestcallsCallbackModelTestcallsCallModelTestcallsAnalyzerTestcallsJsonReporterTestcallsTextReporterTestcalls
Relations§
Instantiated in 2
Method calls 4
- method-call SqlCatalog\Core\Analysis\Interpreter::analyze() packages/sql-catalog/src/Core/Analysis/Interpreter.php:115
- method-call SqlCatalog\Core\Analysis\Interpreter::sinkOf() packages/sql-catalog/src/Core/Analysis/Interpreter.php:248
- method-call SqlCatalog\Core\Analysis\Interpreter::unidentified() packages/sql-catalog/src/Core/Analysis/Interpreter.php:295
- method-call SqlCatalog\Extension\Laravel\BuilderQueries::statements() packages/sql-catalog/src/Extension/Laravel/BuilderQueries.php:51