classEntryBinder
final class EntryBinder
Binds what a path still needs when it reaches the start of its body.
A parameter is bound to what each call of the body passes for it, which is worked out at the call the same way the statement was worked out at the database call. A property of $this is bound to each value the class can leave it holding. A name read at the top of a file is bound to what an extension says it holds. Whatever cannot be bound this way is left open, and says why: nothing calls the body, the budget ran out, or the name is simply not defined anywhere the analysis can see.
Methods§
public function __construct(
Callers $callers,
ExpressionEvaluator $expressions,
EvaluationBudget $budget,
?DeclaredGlobals $globals = null,
?PropertyWrites $properties = null,
)Wires the binder to what it looks for callers and property values with.
Parameters
$callers | Callers | |
$expressions | ExpressionEvaluator | |
$budget | EvaluationBudget | |
$globals | ?DeclaredGlobals | |
$properties | ?PropertyWrites |
Calls 2
- new DeclaredGlobals line 64
- new TypeReader line 66
The ways in, with those beyond what the budget can run one at a time joined into one.
Every way in runs the whole path, so a long path with many ways in costs their product. The ways the budget cannot pay for are joined value by value into a single way in: every value is still there, and the result says that its values were paired without knowing they go together.
Parameters
$bindings | list<Binding> | |
$limit | int |
Returns
list<Binding>Called from 1
The ways into the body a path arrived at the start of, each binding what the path still needs.
Returns
list<Binding>Test cases 1
Called from 1
Calls 8
- method-call EntryBinder::parameterBindings() line 106
- method-call Deriver::classOf() line 107
- function-call
str_starts_withline 113 - class-const FreeNames::THIS() line 113
- function-call
substrline 114 - function-call
strlenline 114 - function-call
countline 115 - method-call EntryBinder::withProperty() line 116
public function withProperty(
list<Binding> $bindings,
string $name,
list<Domain> $values,
bool $combined = false,
): list<Binding>The ways in, one for each value a property can hold on each of them.
Properties are worked out one at a time, so once more than one of them can hold several values, the pairings are not known to occur together and the ways in say so.
Returns
list<Binding>Called from 1
public function parameterValues(
FunctionLike $body,
string $name,
int $depth,
Deriver $deriver,
): list<Domain>What a parameter of a body can be, for every way into the body.
Parameters
$body | FunctionLike | |
$name | string | |
$depth | int | |
$deriver | Deriver |
Returns
list<Domain>Calls 3
- method-call EntryBinder::parameterBindings() line 165
- new Arrival line 165
- static-call Pending::needing() line 165
public function evaluateConstant(Expr $expression, ?string $className): DomainThe value of an expression that reads nothing but constants, such as a property default.
Parameters
$expression | Expr | |
$className | ?string |
Returns
Calls 4
- method-call ExpressionEvaluator::evaluate() line 177
- new Environment line 177
- new FunctionScope line 177
- class-const FunctionScope::MAIN() line 177
The ways into the body, each binding the parameters and other names the path still needs.
A local with no reaching definition starts absent. Reading it yields null; its existence remains separate from the values assigned later. Parameters, declared globals and exhausted paths keep their open values.
Returns
list<Binding>Called from 2
Calls 18
- class-const FunctionScope::MAIN() line 192
- method-call Deriver::nameOf() line 192
- new Binding line 195
- method-call EntryBinder::leaveOpen() line 195
- class-const Origin::Budget() line 195
- method-call EntryBinder::fileScope() line 198
- method-call EntryBinder::parametersOf() line 201
- new Environment line 202
- function-call
array_diff_keyline 203 - class-const FreeNames::THIS() line 204
- function-call
str_starts_withline 204 - method-call Environment::markAbsent() line 205
- method-call EvaluationBudget::isExhausted() line 211
- method-call EntryBinder::withParameters() line 212
- method-call Callers::of() line 214
- method-call EntryBinder::openOrigin() line 216
- class-const Origin::Parameter() line 216
- method-call EntryBinder::fromCallers() line 221
public function fromCallers(
CallerSet $callers,
array<string, array{int, Param}> $parameters,
Environment $outside,
string $name,
int $depth,
Deriver $deriver,
): list<Binding>One way in for every way each call can pass the arguments the path needs.
When not every caller could be asked — there are more than the limit, the budget ran out partway, or a call might reach the body without that being certain — every way in found is marked as cut short, not only the ones found after the search stopped: the set as a whole is what is incomplete.
Parameters
$callers | CallerSet | |
$parameters | array<string, array{int, Param}> | |
$outside | Environment | |
$name | string | |
$depth | int | |
$deriver | Deriver |
Returns
list<Binding>Called from 1
Calls 13
- function-call
countline 241 - class-const Deriver::MAX_CALLERS() line 241
- function-call
array_sliceline 243 - method-call EvaluationBudget::isExhausted() line 244
- method-call EntryBinder::argumentsFor() line 248
- function-call
array_valuesline 249 - function-call
array_filterline 249 - method-call Deriver::solve() line 250
- method-call Environment::copy() line 251
- method-call EntryBinder::defaultOf() line 255
- function-call
array_mapline 262 - new Binding line 263
- function-call
array_mergeline 265
public function argumentsFor(
CallLike $call,
array<string, array{int, Param}> $parameters,
): array<string, Expr|null>The argument a call passes for each needed parameter, or null where it passes none.
Parameters
$call | CallLike | |
$parameters | array<string, array{int, Param}> |
Returns
array<string, Expr|null>Called from 1
public function defaultOf(Param $parameter): DomainWhat a parameter holds when a call does not pass it.
Parameters
$parameter | Param |
Returns
Called from 1
Calls 7
- function-call
is_stringline 301 - method-call ExpressionEvaluator::evaluate() line 303
- new Environment line 303
- new FunctionScope line 303
- static-call Domain::opaque() line 306
- method-call TypeReader::read() line 306
- class-const Origin::Parameter() line 306
public function openOrigin(): OriginWhy a parameter no caller could be asked about is left open: the budget, or there being no caller.
Returns
Called from 2
- method-call SqlCatalog\Core\Analysis\Derivation\EntryBinder::parameterBindings() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:216
- method-call SqlCatalog\Core\Analysis\Derivation\EntryBinder::parameterBindings() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:225
Calls 3
- method-call EvaluationBudget::isExhausted() line 314
- class-const Origin::Budget() line 314
- class-const Origin::Parameter() line 314
public function parametersOf(
FunctionLike $body,
array<string, true> $needs,
): array<string, array{int, Param}>The parameters of a body among the names a path needs, with their positions.
Parameters
$body | FunctionLike | |
$needs | array<string, true> |
Returns
array<string, array{int, Param}>Called from 1
public function withParameters(
Environment $environment,
array<string, array{int, Param}> $parameters,
Origin $origin,
): EnvironmentThe environment with every needed parameter left open, for the given reason.
Parameters
$environment | Environment | |
$parameters | array<string, array{int, Param}> | |
$origin | Origin |
Returns
Called from 3
- method-call SqlCatalog\Core\Analysis\Derivation\EntryBinder::parameterBindings() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:212
- method-call SqlCatalog\Core\Analysis\Derivation\EntryBinder::parameterBindings() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:218
- method-call SqlCatalog\Core\Analysis\Derivation\EntryBinder::parameterBindings() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:225
Calls 3
- method-call Environment::copy() line 343
- static-call Domain::opaque() line 345
- method-call TypeReader::read() line 345
public function leaveOpen(array<string, true> $needs, Origin $origin): EnvironmentEvery needed name left open, for the given reason.
Parameters
$needs | array<string, true> | |
$origin | Origin |
Returns
Called from 1
Calls 4
- new Environment line 358
- method-call Environment::write() line 360
- static-call Domain::opaque() line 360
- static-call TypeShape::unknown() line 360
public function fileScope(array<string, true> $needs): EnvironmentWhat the names code at the top of a file reads without defining are known to hold.
Such code runs in the global scope, so a name it reads was set by whatever ran before it. An extension may say what that is; otherwise it is left open.
Parameters
$needs | array<string, true> |
Returns
Test cases 1
Called from 1
Calls 8
- new Environment line 377
- method-call DeclaredGlobals::declared() line 379
- method-call Environment::write() line 380
- static-call Domain::of() line 381
- new ObjectTerm line 381
- static-call Domain::opaque() line 382
- static-call TypeShape::unknown() line 382
- class-const Origin::Unresolved() line 382
Private surface 6§
Implementation details, listed for orientation only.
private Callers $callersprivate ExpressionEvaluator $expressionsprivate EvaluationBudget $budgetprivate DeclaredGlobals $globalsprivate ?PropertyWrites $propertiesprivate TypeReader $typesTest cases 28§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 2
Other tests reaching this symbol 26
CatalogCommandTestcallsCallEvaluatorTestcallsConstantReaderTestcallsCalleeReturnsTestcallsCallersTestcallsDeriverTest::testBinderIsTheEntryBinderTheDeriverWasWiredWithcallsDeriverTest::testEvaluatorIsTheEvaluatorTheDeriverWasWiredWithcallsDeriverTest::testSolveReadsWhatTheGoalsNeedWithTheNamesItWasGivencallsCallbackEffectsTestcallsPropertyWritesTest::testValuesOfCollectsWhatEveryWriterLeavescallsPropertyWritesTest::testValuesOfSkipsTheWritersOnceTheBudgetIsSpentcallsSliceExecutorTestcallsExpressionEvaluatorTestcallsRegistryTestcallsInterpreterTestcallsModelQueriesTestcallsReferenceEvaluatorTestcallsCallContextTestcallsQueryModelInterfaceTestcallsBuilderCallsTestcallsBuilderQueriesTestcallsCallbackModelTestcallsCallModelTestcallsAnalyzerTestcallsJsonReporterTestcallsTextReporterTestcalls
Relations§
Instantiated in 1
Method calls 2
Type declarations 3
- type SqlCatalog\Core\Analysis\Derivation\Deriver packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:56
- type SqlCatalog\Core\Analysis\Derivation\Deriver packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:71
- type SqlCatalog\Core\Analysis\Derivation\Deriver packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:87