classModifiedNames
final class ModifiedNames
The names a statement may assign, wherever inside it the assignment is written.
Walking back over a statement that assigns none of the names still being looked for learns nothing, so this is what decides whether a branch has to be split into its arms at all. The answer is remembered per statement, because the same statement is walked back over once for every path that crosses it.
Methods§
public function __construct(?FreeNames $names = null, private ?ObjectEffects $objects = null)Builds the reader over the naming the rest of the derivation uses.
Parameters
$names | ?FreeNames | |
$objects | ?ObjectEffects |
public function touches(Node $node, array<string, true> $wanted): boolWhether the node may assign any of the given names.
Parameters
$node | Node | |
$wanted | array<string, true> |
Returns
boolTest cases 2
Called from 3
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:46
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\BackwardSlicer::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/BackwardSlicer.php:282
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\LoopPasses::continues() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/LoopPasses.php:234
Calls 3
- method-call ModifiedNames::of() line 52
- class-const WriteEffects::ALL() line 54
- function-call
array_intersect_keyline 54
public function of(Node $node): array<string, true>Every name the node may assign.
Parameters
$node | Node |
Returns
array<string, true>Test cases 1
Called from 7
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::touches() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:52
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::collect() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:90
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:45
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::within() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:77
- method-call SqlCatalog\Core\Analysis\Derivation\SliceExecutor::writtenBy() packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:191
- method-call SqlCatalog\Core\Analysis\Derivation\SliceExecutor::apply() packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:251
- method-call SqlCatalog\Core\Analysis\Derivation\SliceExecutor::apply() packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:256
Calls 1
- method-call ModifiedNames::collect() line 68
public function collect(Node $node): array<string, true>Every name the node may assign, worked out from scratch.
Parameters
$node | Node |
Returns
array<string, true>Test cases 1
Called from 1
Calls 5
- method-call ModifiedNames::own() line 84
- new ReferenceEffects line 85
- function-call
get_object_varsline 87 - function-call
is_arrayline 88 - method-call ModifiedNames::of() line 90
public function own(Node $node): array<string, true>The names the node itself assigns, leaving aside what its children assign.
Parameters
$node | Node |
Returns
array<string, true>Test cases 2
Called from 6
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::collect() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:84
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:49
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::within() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:75
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::declaration() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:97
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\LoopPasses::binding() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/LoopPasses.php:157
- method-call SqlCatalog\Core\Analysis\Derivation\SliceExecutor::declare() packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:298
Calls 5
- method-call ModifiedNames::targets() line 106
- method-call WriteEffects::own() line 106
- new WriteEffects line 106
- method-call ModifiedNames::all() line 113
- new ReferenceEffects line 132
public function tracksObjects(): boolWhether object calls are retained as whole expression steps.
Returns
boolTest cases 1
Called from 2
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::within() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:75
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\BackwardSlicer::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/BackwardSlicer.php:288
public function targets(Node $target): array<string, true>The names written by assigning to the given target.
Parameters
$target | Node |
Returns
array<string, true>Test cases 1
Called from 16
- method-call SqlCatalog\Core\Analysis\CallEvaluator::applyEffects() packages/sql-catalog/src/Core/Analysis/CallEvaluator.php:122
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::own() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:106
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::own() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:110
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::own() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:118
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::own() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:124
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::own() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:127
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::targets() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:153
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::targets() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:166
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::all() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:204
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:49
- method-call SqlCatalog\Core\Analysis\Effect\ReferenceEffects::collect() packages/sql-catalog/src/Core/Analysis/Effect/ReferenceEffects.php:75
- method-call SqlCatalog\Core\Analysis\Effect\ReferenceEffects::collect() packages/sql-catalog/src/Core/Analysis/Effect/ReferenceEffects.php:88
- method-call SqlCatalog\Core\Analysis\Effect\ReferenceEffects::collect() packages/sql-catalog/src/Core/Analysis/Effect/ReferenceEffects.php:92
- method-call SqlCatalog\Core\Analysis\Effect\WriteEffects::own() packages/sql-catalog/src/Core/Analysis/Effect/WriteEffects.php:49
- method-call SqlCatalog\Core\Analysis\Effect\WriteEffects::assignment() packages/sql-catalog/src/Core/Analysis/Effect/WriteEffects.php:67
- method-call SqlCatalog\Core\Analysis\Effect\WriteEffects::arguments() packages/sql-catalog/src/Core/Analysis/Effect/WriteEffects.php:118
Calls 3
- method-call ModifiedNames::targets() line 153
- method-call FreeNames::propertyName() line 155
- method-call ModifiedNames::baseName() line 158
public function baseName(Node $target): ?stringThe name an assignment target writes into, looking through element writes.
$sql['where'][] = … writes into sql; $this->parts[] = … writes into this->parts. Anything else, such as a variable variable, has no name.
Parameters
$target | Node |
Returns
?stringTest cases 1
Called from 3
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::targets() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:158
- method-call SqlCatalog\Core\Analysis\Derivation\ModifiedNames::baseName() packages/sql-catalog/src/Core/Analysis/Derivation/ModifiedNames.php:185
- method-call SqlCatalog\Core\Analysis\Derivation\PropertyWrites::writes() packages/sql-catalog/src/Core/Analysis/Derivation/PropertyWrites.php:126
Calls 3
- method-call ModifiedNames::baseName() line 185
- function-call
is_stringline 188 - method-call FreeNames::propertyName() line 191
public function all(array<array-key, Node> $targets): array<string, true>The names written by each of the given targets.
Parameters
$targets | array<array-key, Node> |
Returns
array<string, true>Test cases 1
Called from 2
Calls 1
- method-call ModifiedNames::targets() line 204
Private surface 4§
Implementation details, listed for orientation only.
private WeakMap<Node, array<string, true>> $rememberedprivate FreeNames $namesprivate ?ReferenceEffects $references = nullprivate ?ObjectEffects $objects = nullTest cases 65§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 9
ModifiedNamesTest::testAllNamesWhatEachTargetWritescallsModifiedNamesTest::testBaseNameLooksThroughElementWritescallsModifiedNamesTest::testCollectWorksTheAnswerOutFromScratchcallsModifiedNamesTest::testOfNamesEverythingAStatementMayAssigncallsModifiedNamesTest::testOwnLeavesOutWhatTheChildrenAssigncallsModifiedNamesTest::testOwnRetainsSymbolTableWritesAlongsideObjectEffectscallsModifiedNamesTest::testTargetsNameEveryVariableADestructuringWritescallsModifiedNamesTest::testTouchesSaysWhetherAStatementAssignsAnyWantedNamecallsModifiedNamesTest::testTracksObjectsRequiresAnExplicitEffectModelcalls
Other tests reaching this symbol 56
CatalogCommandTestcallsCallEvaluatorTestcallsConstantReaderTestcallsCalleeReturnsTestcallsCallersTestcallsDeriverTestcallsEntryBinderTestcallsCallbackEffectsTest::testApplyFollowsMutationsOfTheCallbackParametercallsCallbackEffectsTest::testApplyLeavesCallbacksWithoutAReceiverOpencallsCallbackEffectsTest::testApplyRunsClosureEffectsThroughCapturedAliasesOfItsReceivercallsCallbackEffectsTest::testBindKeepsOnlyExplicitClosureCapturesAndPassedArgumentscallsPropertyWritesTest::testValuesOfCollectsWhatEveryWriterLeavescallsPropertyWritesTest::testValuesOfSkipsTheWritersOnceTheBudgetIsSpentcallsAssignmentStepsTest::testDeclarationDefinesWhatAGlobalListsButKeepsLookingPastAnUnsetcallsAssignmentStepsTest::testOverWalksBackOverTheLastAssignmentFirstcallsAssignmentStepsTest::testReplacesIsTrueOnlyForAnAssignmentThatOverwritesItsTargetcallsAssignmentStepsTest::testWithinKeepsConditionalWritesTogethercallsAssignmentStepsTest::testWithinLeavesOutWhatAClosureAssignscallsBackwardSlicerTestcallsLoopPassesTest::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::applyEffects() packages/sql-catalog/src/Core/Analysis/CallEvaluator.php:122
- new SqlCatalog\Core\Analysis\Derivation\PropertyWrites::__construct() packages/sql-catalog/src/Core/Analysis/Derivation/PropertyWrites.php:52
- new SqlCatalog\Core\Analysis\Derivation\Slice\BackwardSlicer::__construct() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/BackwardSlicer.php:63
- new SqlCatalog\Core\Analysis\Derivation\SliceExecutor::__construct() packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:78
- new SqlCatalog\Core\Analysis\Effect\ReferenceEffects::collect() packages/sql-catalog/src/Core/Analysis/Effect/ReferenceEffects.php:70
- new SqlCatalog\Core\Analysis\Effect\WriteEffects::own() packages/sql-catalog/src/Core/Analysis/Effect/WriteEffects.php:41
- new SqlCatalog\Core\Analysis\Effect\WriteEffects::assignment() packages/sql-catalog/src/Core/Analysis/Effect/WriteEffects.php:67
- new SqlCatalog\Core\Analysis\Effect\WriteEffects::arguments() packages/sql-catalog/src/Core/Analysis/Effect/WriteEffects.php:105
- new SqlCatalog\Core\Analysis\Interpreter::deriverFor() packages/sql-catalog/src/Core/Analysis/Interpreter.php:149
Method calls 25
- method-call SqlCatalog\Core\Analysis\CallEvaluator::applyEffects() packages/sql-catalog/src/Core/Analysis/CallEvaluator.php:122
- method-call SqlCatalog\Core\Analysis\Derivation\PropertyWrites::writes() packages/sql-catalog/src/Core/Analysis/Derivation/PropertyWrites.php:126
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:45
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:46
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:49
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:49
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::within() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:75
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::within() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:75
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::within() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:77
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps::declaration() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:97
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\BackwardSlicer::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/BackwardSlicer.php:282
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\BackwardSlicer::over() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/BackwardSlicer.php:288
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\LoopPasses::binding() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/LoopPasses.php:157
- method-call SqlCatalog\Core\Analysis\Derivation\Slice\LoopPasses::continues() packages/sql-catalog/src/Core/Analysis/Derivation/Slice/LoopPasses.php:234
- method-call SqlCatalog\Core\Analysis\Derivation\SliceExecutor::writtenBy() packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:191
- method-call SqlCatalog\Core\Analysis\Derivation\SliceExecutor::apply() packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:251
- method-call SqlCatalog\Core\Analysis\Derivation\SliceExecutor::apply() packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:256
- method-call SqlCatalog\Core\Analysis\Derivation\SliceExecutor::declare() packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:298
- method-call SqlCatalog\Core\Analysis\Effect\ReferenceEffects::collect() packages/sql-catalog/src/Core/Analysis/Effect/ReferenceEffects.php:75
- method-call SqlCatalog\Core\Analysis\Effect\ReferenceEffects::collect() packages/sql-catalog/src/Core/Analysis/Effect/ReferenceEffects.php:85
- method-call SqlCatalog\Core\Analysis\Effect\ReferenceEffects::collect() packages/sql-catalog/src/Core/Analysis/Effect/ReferenceEffects.php:88
- method-call SqlCatalog\Core\Analysis\Effect\ReferenceEffects::collect() packages/sql-catalog/src/Core/Analysis/Effect/ReferenceEffects.php:92
- method-call SqlCatalog\Core\Analysis\Effect\WriteEffects::own() packages/sql-catalog/src/Core/Analysis/Effect/WriteEffects.php:49
- method-call SqlCatalog\Core\Analysis\Effect\WriteEffects::assignment() packages/sql-catalog/src/Core/Analysis/Effect/WriteEffects.php:67
- method-call SqlCatalog\Core\Analysis\Effect\WriteEffects::arguments() packages/sql-catalog/src/Core/Analysis/Effect/WriteEffects.php:118
Type declarations 10
- type SqlCatalog\Core\Analysis\Derivation\PropertyWrites packages/sql-catalog/src/Core/Analysis/Derivation/PropertyWrites.php:33
- type SqlCatalog\Core\Analysis\Derivation\PropertyWrites packages/sql-catalog/src/Core/Analysis/Derivation/PropertyWrites.php:48
- type SqlCatalog\Core\Analysis\Derivation\Slice\AssignmentSteps packages/sql-catalog/src/Core/Analysis/Derivation/Slice/AssignmentSteps.php:28
- 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:43
- type SqlCatalog\Core\Analysis\Derivation\Slice\BackwardSlicer packages/sql-catalog/src/Core/Analysis/Derivation/Slice/BackwardSlicer.php:58
- type SqlCatalog\Core\Analysis\Derivation\Slice\LoopPasses packages/sql-catalog/src/Core/Analysis/Derivation/Slice/LoopPasses.php:34
- type SqlCatalog\Core\Analysis\Derivation\Slice\LoopPasses packages/sql-catalog/src/Core/Analysis/Derivation/Slice/LoopPasses.php:46
- type SqlCatalog\Core\Analysis\Derivation\SliceExecutor packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:60
- type SqlCatalog\Core\Analysis\Derivation\SliceExecutor packages/sql-catalog/src/Core/Analysis/Derivation/SliceExecutor.php:72