classFreeNames
final class FreeNames
The names an expression reads, which are what its value depends on.
A variable is named as itself; a property of the object a method runs on is named this->property, because an assignment to it earlier in the body is a definition in the same way an assignment to a variable is; the object itself is named this. Superglobals are not named: nothing in the source defines them, so there is nothing to look for.
A database call written inside the expression reads less than it passes. What a preparing or composing call hands back depends on the statement text alone, and what a query hands back does not depend on its arguments at all, so the values it binds are not looked for. Without this, a statement built from $wpdb->prepare('(%s, %s)', $option, $value) would chase every value it binds through every function that computes one, and none of that can change the text.
Constants§
public const THIS = 'this'The name a property of $this is tracked under.
Methods§
public function __construct(
list<SinkSpec> $sinks = [],
?ExternalInput $external = null,
bool $trackObjectEffects = false,
)Builds the reader over the database calls whose arguments it reads selectively.
Parameters
$sinks | list<SinkSpec> | |
$external | ?ExternalInput | |
$trackObjectEffects | bool |
Calls 6
- new ExternalInput line 55
- class-const SinkRole::Modelled() line 58
- function-call
strtolowerline 59 - function-call
ltrimline 59 - class-const SinkRole::Compose() line 61
- class-const SinkRole::Prepare() line 61
public function of(list<Node> $nodes): array<string, true>The names read by any of the given expressions.
Parameters
$nodes | list<Node> |
Returns
array<string, true>Test cases 3
Called from 4
- method-call SqlCatalog\Core\Analysis\CallEvaluator::invalidateEscapes() packages/sql-catalog/src/Core/Analysis/CallEvaluator.php:354
- method-call SqlCatalog\Core\Analysis\Derivation\CalleeReturns::returned() packages/sql-catalog/src/Core/Analysis/Derivation/CalleeReturns.php:142
- method-call SqlCatalog\Core\Analysis\Derivation\Deriver::solve() packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:113
- method-call SqlCatalog\Core\Analysis\Derivation\Deriver::solveAtExits() packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:136
Calls 1
- method-call FreeNames::read() line 78
public function read(Node $node): array<string, true>The names one node reads.
Parameters
$node | Node |
Returns
array<string, true>Test cases 1
Called from 13
- method-call SqlCatalog\Core\Analysis\Derivation\FreeNames::of() packages/sql-catalog/src/Core/Analysis/Derivation/FreeNames.php:78
- method-call SqlCatalog\Core\Analysis\Derivation\FreeNames::read() packages/sql-catalog/src/Core/Analysis/Derivation/FreeNames.php:95
- method-call SqlCatalog\Core\Analysis\Derivation\FreeNames::read() packages/sql-catalog/src/Core/Analysis/Derivation/FreeNames.php:123
- method-call SqlCatalog\Core\Analysis\Derivation\FreeNames::sinkCall() packages/sql-catalog/src/Core/Analysis/Derivation/FreeNames.php:160
- method-call SqlCatalog\Core\Analysis\Derivation\FreeNames::sinkCall() packages/sql-catalog/src/Core/Analysis/Derivation/FreeNames.php:166
- method-call SqlCatalog\Core\Analysis\Derivation\FreeNames::targetReads() packages/sql-catalog/src/Core/Analysis/Derivation/FreeNames.php:185
- method-call SqlCatalog\Core\Analysis\Derivation\FreeNames::targetReads() packages/sql-catalog/src/Core/Analysis/Derivation/FreeNames.php:188
- method-call SqlCatalog\Core\Analysis\Derivation\FreeNames::targetReads() packages/sql-catalog/src/Core/Analysis/Derivation/FreeNames.php:194
- method-call SqlCatalog\Core\Analysis\Derivation\FreeNames::arrowFunction() packages/sql-catalog/src/Core/Analysis/Derivation/FreeNames.php:240
- method-call SqlCatalog\Core\Analysis\Derivation\Objects\ObjectEffects::writes() packages/sql-catalog/src/Core/Analysis/Derivation/Objects/ObjectEffects.php:67
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:51
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\LoopPasses::entering() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/LoopPasses.php:187
- method-call SqlCatalog\Extension\Laravel\CallbackModel::nested() packages/sql-catalog/src/Extension/Laravel/CallbackModel.php:111
Calls 9
- method-call FreeNames::variable() line 92
- method-call FreeNames::read() line 95
- method-call FreeNames::targetReads() line 95
- method-call FreeNames::propertyName() line 97
- method-call FreeNames::arrowFunction() line 110
- method-call FreeNames::sinkArgumentsOf() line 113
- method-call FreeNames::sinkCall() line 115
- function-call
get_object_varsline 120 - function-call
is_arrayline 121
public function sinkArgumentsOf(CallLike $call): array<int, true>|nullThe argument positions whose values decide what a database call hands back, or null when the call is not written as one.
Parameters
$call | CallLike |
Returns
array<int, true>|nullCalled from 1
public function sinkCall(CallLike $call, array<int, true> $positions): array<string, true>The names a database call reads: what it is called on, and the arguments its result depends on.
Parameters
$call | CallLike | |
$positions | array<int, true> |
Returns
array<string, true>Test cases 1
Called from 1
Calls 3
- method-call FreeNames::read() line 160
- method-call
CallLike::isFirstClassCallable()line 161 - method-call
CallLike::getArgs()line 164
public function targetReads(Node $target): array<string, true>The names an assignment target reads without being what it writes.
Writing $rows[$key] reads $key, and reads $rows too, since the element is added to whatever the array already held. Writing $sql reads nothing: the old value is simply replaced.
Parameters
$target | Node |
Returns
array<string, true>Called from 2
Calls 2
- method-call FreeNames::read() line 185
- method-call FreeNames::targetReads() line 194
public function variable(Variable $node): array<string, true>The name a variable is read under, or nothing when it is external or not a plain name.
Parameters
$node | Variable |
Returns
array<string, true>Test cases 1
Called from 2
Calls 2
- function-call
is_stringline 211 - method-call ExternalInput::isVariable() line 211
public function propertyName(Node $node): ?stringThe tracked name of a property of $this, or null when the node is not one.
Parameters
$node | Node |
Returns
?stringTest cases 1
Called from 4
- method-call SqlCatalog\Core\Analysis\Derivation\FreeNames::read() packages/sql-catalog/src/Core/Analysis/Derivation/FreeNames.php:97
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::targets() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:155
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::baseName() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:191
- method-call SqlCatalog\Core\Analysis\Derivation\Objects\ObjectEffects::root() packages/sql-catalog/src/Core/Analysis/Derivation/Objects/ObjectEffects.php:98
Calls 1
- class-const FreeNames::THIS() line 226
public function arrowFunction(ArrowFunction $node): array<string, true>The names an arrow function captures from the scope it is written in.
Parameters
$node | ArrowFunction |
Returns
array<string, true>Test cases 1
Called from 1
Calls 2
- method-call FreeNames::read() line 240
- function-call
is_stringline 242
Private surface 3§
Implementation details, listed for orientation only.
private ExternalInput $externalprivate array<string, array<int, true>> $sinkArguments = []private bool $trackObjectEffects = falseTest cases 67§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
FreeNamesTest::testArrowFunctionLeavesOutItsOwnParameterscallsFreeNamesTest::testOfJoinsTheNamesOfEveryExpressioncallsFreeNamesTest::testPropertyNameNamesOnlyAPropertyOfThiscallsFreeNamesTest::testReadNamesWhatTheValueDependsOncallsFreeNamesTest::testSinkArgumentsOfNamesTheArgumentsADatabaseCallsResultDependsOncallsFreeNamesTest::testSinkCallReadsOnlyWhatTheResultDependsOncallsFreeNamesTest::testTargetReadsCountTheElementWrittenIntoButNotAReplacedVariablecallsFreeNamesTest::testVariableLeavesOutExternalInputcalls
Other tests reaching this symbol 59
CatalogCommandTestcallsCallEvaluatorTestcallsConstantReaderTestcallsCalleeReturnsTestcallsCallersTestcallsDeriverTest::testSolveReadsWhatTheGoalsNeedWithTheNamesItWasGivencallsEntryBinderTestcallsModifiedNamesTestcallsCallbackEffectsTest::testApplyFollowsMutationsOfTheCallbackParametercallsCallbackEffectsTest::testApplyLeavesCallbacksWithoutAReceiverOpencallsCallbackEffectsTest::testApplyRunsClosureEffectsThroughCapturedAliasesOfItsReceivercallsCallbackEffectsTest::testBindKeepsOnlyExplicitClosureCapturesAndPassedArgumentscallsObjectEffectsTestcallsPropertyWritesTest::testValuesOfCollectsWhatEveryWriterLeavescallsPropertyWritesTest::testValuesOfSkipsTheWritersOnceTheBudgetIsSpentcallsAssignmentStepsTest::testDeclarationDefinesWhatAGlobalListsButKeepsLookingPastAnUnsetcallsAssignmentStepsTest::testOverWalksBackOverTheLastAssignmentFirstcallsAssignmentStepsTest::testReplacesIsTrueOnlyForAnAssignmentThatOverwritesItsTargetcallsAssignmentStepsTest::testWithinKeepsConditionalWritesTogethercallsAssignmentStepsTest::testWithinLeavesOutWhatAClosureAssignscallsBackwardSlicerTest::testSliceFromAnArrowFunctionTakesWhatItCapturesFromWhereItIsWrittencallsBackwardSlicerTest::testSliceFromKeepsWhatTheCallDependsOnInTheOrderItRunscallsLoopPassesTest::testBindingIsAStepOnlyForAPathThatNeedsTheLoopsVariablescallsLoopPassesTest::testBodyOfIsWhatALoopRepeatscallsLoopPassesTest::testBoundSaysWhetherAPathTookOneOfTheLoopsPassescallsLoopPassesTest::testContinuesSaysWhetherAnotherPassCouldChangeWhatIsNeededcallsLoopPassesTest::testEnteringReadsWhatALoopGoesOverBeforeItsFirstPasscallsLoopPassesTest::testExpressionsWalkBackOverAListLastFirstcallsLoopPassesTest::testIsLoopRecognisesEveryKindOfLoopcallsLoopPassesTest::testLeaveBodyFollowsAPointInsideALoopBackThroughEarlierPassescallsLoopPassesTest::testPassWalksBackOverOneWholePasscallsLoopPassesTest::testRunsListTheStatementAfterEachNumberOfPassesUpToTheLimitcallsLoopPassesTest::testRunsOfADoWhileAlwaysIncludeAPasscallsLoopPassesTest::testRunsStopOnceAPassCannotChangeWhatIsNeededcallsLoopPassesTest::testRunsTakeExactlyAsManyPassesAsAWrittenOutArrayHasElementscallsLoopPassesTest::testWrittenPassesCountsOnlyAnArrayWrittenOutInFullcallsSliceExecutorTestcallsReferenceEffectsTestcallsWriteEffectsTestcallsExpressionEvaluatorTestcallsRegistryTestcallsInterpreterTestcallsModelQueriesTestcallsReferenceEvaluatorTestcallsCallContextTestcallsModelContextTest::testKeepsTheModelContractInputscallsQueryModelInterfaceTestcallsBuilderCallsTestcallsBuilderQueriesTestcallsCallbackModelTest::testApplyRunsSourceDeclaredLocalScopescallsCallbackModelTest::testCheckedPreservesAVisibleGapWhenTheCallbackExceedsItsBudgetcallsCallbackModelTest::testClosedRejectsWidenedResultsAndForeignIdentitiescallsCallbackModelTest::testConditionalKeepsBothOutcomesOfWhenAndUnlesscallsCallbackModelTest::testNestedRestoresOuterClausesAndGroupsOnlyNewPredicatescallsCallModelTestcallsLaravelExtensionTest::testModelsRegistersLaravelSemanticsThroughTheOptionalContractcallsAnalyzerTestcallsJsonReporterTestcallsTextReporterTestcalls
Relations§
Instantiated in 9
- new SqlCatalog\Core\Analysis\CallEvaluator::invalidateEscapes() packages/sql-catalog/src/Core/Analysis/CallEvaluator.php:354
- new SqlCatalog\Core\Analysis\Derivation\CalleeReturns::__construct() packages/sql-catalog/src/Core/Analysis/Derivation/CalleeReturns.php:56
- new SqlCatalog\Core\Analysis\Derivation\Deriver::__construct() packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:80
- new SqlCatalog\Core\Analysis\Derivation\ModifiedNames::__construct() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:41
- new SqlCatalog\Core\Analysis\Derivation\Objects\ObjectEffects::writes() packages/sql-catalog/src/Core/Analysis/Derivation/Objects/ObjectEffects.php:67
- new SqlCatalog\Core\Analysis\Derivation\Objects\ObjectEffects::root() packages/sql-catalog/src/Core/Analysis/Derivation/Objects/ObjectEffects.php:98
- new SqlCatalog\Core\Analysis\Derivation\Slice\BackwardSlicer::__construct() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/BackwardSlicer.php:62
- new SqlCatalog\Core\Analysis\Interpreter::deriverFor() packages/sql-catalog/src/Core/Analysis/Interpreter.php:148
- new SqlCatalog\Extension\Laravel\CallbackModel::nested() packages/sql-catalog/src/Extension/Laravel/CallbackModel.php:111
Method calls 11
- method-call SqlCatalog\Core\Analysis\CallEvaluator::invalidateEscapes() packages/sql-catalog/src/Core/Analysis/CallEvaluator.php:354
- method-call SqlCatalog\Core\Analysis\Derivation\CalleeReturns::returned() packages/sql-catalog/src/Core/Analysis/Derivation/CalleeReturns.php:142
- method-call SqlCatalog\Core\Analysis\Derivation\Deriver::solve() packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:113
- method-call SqlCatalog\Core\Analysis\Derivation\Deriver::solveAtExits() packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:136
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::targets() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:155
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::baseName() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:191
- method-call SqlCatalog\Core\Analysis\Derivation\Objects\ObjectEffects::writes() packages/sql-catalog/src/Core/Analysis/Derivation/Objects/ObjectEffects.php:67
- method-call SqlCatalog\Core\Analysis\Derivation\Objects\ObjectEffects::root() packages/sql-catalog/src/Core/Analysis/Derivation/Objects/ObjectEffects.php:98
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:51
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\LoopPasses::entering() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/LoopPasses.php:187
- method-call SqlCatalog\Extension\Laravel\CallbackModel::nested() packages/sql-catalog/src/Extension/Laravel/CallbackModel.php:111
Constant reads 8
- class-const SqlCatalog\Core\Analysis\Derivation\CalleeReturns::returned() packages/sql-catalog/src/Core/Analysis/Derivation/CalleeReturns.php:145
- class-const SqlCatalog\Core\Analysis\Derivation\Callers::reaches() packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:182
- class-const SqlCatalog\Core\Analysis\Derivation\EntryBinder::bindings() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:113
- class-const SqlCatalog\Core\Analysis\Derivation\EntryBinder::bindings() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:114
- class-const SqlCatalog\Core\Analysis\Derivation\EntryBinder::parameterBindings() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:204
- class-const SqlCatalog\Core\Analysis\Derivation\PropertyWrites::valuesOf() packages/sql-catalog/src/Core/Analysis/Derivation/PropertyWrites.php:73
- class-const SqlCatalog\Core\Analysis\Derivation\PropertyWrites::writes() packages/sql-catalog/src/Core/Analysis/Derivation/PropertyWrites.php:123
- class-const SqlCatalog\Core\Analysis\Derivation\Slice\BackwardSlicer::outside() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/BackwardSlicer.php:207
Type declarations 12
- type SqlCatalog\Core\Analysis\Derivation\CalleeReturns packages/sql-catalog/src/Core/Analysis/Derivation/CalleeReturns.php:37
- type SqlCatalog\Core\Analysis\Derivation\CalleeReturns packages/sql-catalog/src/Core/Analysis/Derivation/CalleeReturns.php:50
- type SqlCatalog\Core\Analysis\Derivation\Deriver packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:50
- type SqlCatalog\Core\Analysis\Derivation\Deriver packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:73
- type SqlCatalog\Core\Analysis\Derivation\ModifiedNames packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:32
- type SqlCatalog\Core\Analysis\Derivation\ModifiedNames packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:39
- type SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:26
- type SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:33
- type SqlCatalog\Core\Analysis\Derivation\Slice\BackwardSlicer packages/sql-catalog/src/Core/Analysis/Derivation/Slice/BackwardSlicer.php:41
- type SqlCatalog\Core\Analysis\Derivation\Slice\BackwardSlicer packages/sql-catalog/src/Core/Analysis/Derivation/Slice/BackwardSlicer.php:57
- type SqlCatalog\Core\Analysis\Derivation\Slice\LoopPasses packages/sql-catalog/src/Core/Analysis/Derivation/Slice/LoopPasses.php:32
- type SqlCatalog\Core\Analysis\Derivation\Slice\LoopPasses packages/sql-catalog/src/Core/Analysis/Derivation/Slice/LoopPasses.php:45