classCallers
final class Callers
The calls in the source that reach a given function or method.
A function is reached by the calls written with its name. A method is reached by the calls written with its name on something that can be an instance of its class; what they are written on is worked out the same way any other value is, so $repository->find(…) is a caller of Repository::find when $repository can be a Repository. A call on something whose class could not be worked out is not taken as a caller, since a method of the same name on a built-in class or on a class outside the analyzed files may be the one it reaches; the callers found are then marked as partial instead.
A call written on a class name reaches the method that class has, declared or inherited: parent:: looks from the parent of the class it is written in and self:: from that class itself. Only static:: and a call on an instance can also land in a subclass that overrides the method.
A method of a class an extension models has no callers here. The extension already says what calling it does, and every call of it is read where it is written; reading it again from inside the class, once per caller, would list each of those statements a second time under the class's own line.
Methods§
public function __construct(CallerIndex $calls, ProgramIndex $index, ?SinkMatcher $sinks = null)Wires the lookup to the calls and the declarations it filters them with.
Parameters
$calls | CallerIndex | |
$index | ProgramIndex | |
$sinks | ?SinkMatcher |
The calls that reach a body, in the order they are written.
Parameters
$body | FunctionLike | |
$depth | int | |
$deriver | Deriver |
Returns
Test cases 10
CallersTest::testOfFindsNoCallersOfAClosurecallsCallersTest::testOfFindsNoCallersOfAMethodWrittenOutsideAnyClasscallsCallersTest::testOfFindsTheCallsWrittenWithAFunctionsNamecallsCallersTest::testOfFindsTheExplicitCallsOfAConstructorAsWellAsTheInstantiationscallsCallersTest::testOfFindsTheInstantiationsOfAClassForItsConstructorcallsCallersTest::testOfIsNotPartialWhenEveryCallIsAccountedForcallsCallersTest::testOfKeepsTheCallsThatCanReachTheMethodInTheOrderWrittencallsCallersTest::testOfListsEveryCallerWithoutStoppingAtTheCallerLimitcallsCallersTest::testOfMarksTheCallersPartialWhenACallMightReachTheMethodWithoutThatBeingCertaincallsCallersTest::testOfSkipsClassesAnExtensionModelscalls
Called from 1
Calls 9
- new CallerSet line 65
- method-call Callers::ofFunction() line 65
- method-call Deriver::classOf() line 70
- static-call Domain::of() line 71
- new ObjectTerm line 71
- function-call
strtolowerline 75 - method-call Callers::instantiations() line 75
- method-call CallerIndex::named() line 77
- method-call Callers::reaches() line 78
public function ofFunction(Function_ $function): list<CallLike>The calls written with a function's fully qualified name.
Parameters
$function | Function_ |
Returns
list<CallLike>Test cases 3
Called from 1
Calls 4
- function-call
strtolowerline 95 - method-call CallerIndex::named() line 97
- function-call
ltrimline 102 - function-call
in_arrayline 106
public function instantiations(string $className, Deriver $deriver): list<CallLike>The instantiations that run a class's constructor.
Parameters
$className | string | |
$deriver | Deriver |
Returns
list<CallLike>Test cases 3
Called from 1
Calls 7
- method-call Callers::inheritorsOf() line 122
- method-call CallerIndex::instantiating() line 123
- function-call
in_arrayline 125 - function-call
strtolowerline 125 - method-call Deriver::classOf() line 126
- function-call
strcasecmpline 128 - function-call
ltrimline 128
public function inheritorsOf(string $className): list<string>The classes whose instantiation runs a class's constructor: the class, and every subclass that inherits the constructor rather than declaring its own.
Parameters
$className | string |
Returns
list<string>Test cases 1
Called from 1
Calls 3
- function-call
strtolowerline 144 - function-call
ltrimline 144 - method-call ProgramIndex::findClass() line 151
public function reaches(CallLike $call, string $className, int $depth, Deriver $deriver): ?boolWhether a call written with the method's name can reach the method of that class, or null when that cannot be told.
Parameters
$call | CallLike | |
$className | string | |
$depth | int | |
$deriver | Deriver |
Returns
?boolTest cases 3
Called from 1
Calls 8
- method-call CallerIndex::nameOf() line 166
- method-call Callers::staticTarget() line 171
- function-call
strtolowerline 175 - method-call Callers::related() line 177
- method-call ProgramIndex::isInstanceOf() line 177
- class-const FreeNames::THIS() line 182
- method-call Deriver::classOf() line 183
- method-call Deriver::solveUnlessSpent() line 188
public function staticTarget(StaticCall $call, Deriver $deriver): ?stringThe class a call written on a class name looks its method up from, or null when it cannot be named.
Parameters
$call | StaticCall | |
$deriver | Deriver |
Returns
?stringTest cases 1
Called from 1
Calls 3
- function-call
strtolowerline 215 - method-call Deriver::classOf() line 216
- method-call ProgramIndex::findClass() line 217
Private surface 3§
Implementation details, listed for orientation only.
private CallerIndex $callsprivate ProgramIndex $indexprivate ?SinkMatcher $sinksTest cases 50§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 23
CallersTest::testInheritorsOfListsTheSubclassesThatInheritTheConstructorcallsCallersTest::testInstantiationsIncludeSubclassesThatInheritTheConstructorcallsCallersTest::testInstantiationsMatchTheClassEachNewIsWrittenWithcallsCallersTest::testInstantiationsReadSelfAndStaticAsTheClassTheyAreWrittenIncallsCallersTest::testOfFindsNoCallersOfAClosurecallsCallersTest::testOfFindsNoCallersOfAMethodWrittenOutsideAnyClasscallsCallersTest::testOfFindsTheCallsWrittenWithAFunctionsNamecallsCallersTest::testOfFindsTheExplicitCallsOfAConstructorAsWellAsTheInstantiationscallsCallersTest::testOfFindsTheInstantiationsOfAClassForItsConstructorcallsCallersTest::testOfFunctionFallsBackToTheWrittenNameOfADeclarationWithoutAResolvedOnecallsCallersTest::testOfFunctionLeavesOutCallsOfAnotherFunctionWithTheSameShortNamecallsCallersTest::testOfFunctionMatchesTheGlobalFunctionACallInANamespaceFallsBackTocallsCallersTest::testOfIsNotPartialWhenEveryCallIsAccountedForcallsCallersTest::testOfKeepsTheCallsThatCanReachTheMethodInTheOrderWrittencallsCallersTest::testOfListsEveryCallerWithoutStoppingAtTheCallerLimitcallsCallersTest::testOfMarksTheCallersPartialWhenACallMightReachTheMethodWithoutThatBeingCertaincallsCallersTest::testOfSkipsClassesAnExtensionModelscallsCallersTest::testReachesCannotTellOnceTheBudgetIsSpentcallsCallersTest::testReachesDecidesWhetherACallCanLandInTheMethodcallsCallersTest::testReachesWorksOutTheReceiverOneCallDeepercallsCallersTest::testRelatedHoldsBetweenAClassAndItsHierarchyInEitherDirectioncallsCallersTest::testRelatedStopsAtAnOverrideBetweenTheReceiverAndTheDeclaringClasscallsCallersTest::testStaticTargetIsTheClassTheLookupStartsFromcalls
Other tests reaching this symbol 27
CatalogCommandTestcallsCallEvaluatorTestcallsConstantReaderTestcallsCalleeReturnsTestcallsDeriverTest::testBinderIsTheEntryBinderTheDeriverWasWiredWithcallsDeriverTest::testEvaluatorIsTheEvaluatorTheDeriverWasWiredWithcallsDeriverTest::testSolveReadsWhatTheGoalsNeedWithTheNamesItWasGivencallsEntryBinderTest::testBindingsLeaveThePropertiesAloneWithoutAReaderOfPropertyWritescallsEntryBinderTest::testFileScopeBindsTheGlobalsAnExtensionDeclarescallsCallbackEffectsTestcallsPropertyWritesTest::testValuesOfCollectsWhatEveryWriterLeavescallsPropertyWritesTest::testValuesOfSkipsTheWritersOnceTheBudgetIsSpentcallsSliceExecutorTestcallsExpressionEvaluatorTestcallsRegistryTestcallsInterpreterTestcallsModelQueriesTestcallsReferenceEvaluatorTestcallsCallContextTestcallsQueryModelInterfaceTestcallsBuilderCallsTestcallsBuilderQueriesTestcallsCallbackModelTestcallsCallModelTestcallsAnalyzerTestcallsJsonReporterTestcallsTextReporterTestcalls