classDeriver
final class Deriver
Works out what expressions can be at a point, starting from the point.
The walk back from the point gives the paths through the body and what each still needs at the body's start. A parameter still needed is looked for at every call of the body, where the same question is asked again about the arguments; each call that answers is one more way in. Then every way in is run forward along its path, and the expressions are read at the point. What is still not found at the top — a parameter nothing calls with, a global, a name the budget stopped short of — is left open, saying why.
Constants§
public const MAX_CALLERS = 12How many callers of one body are asked, before the rest are left out and the search marked as cut short.
public const MAX_SOLUTIONS = 32How many ways of reaching one point are kept.
Methods§
public function __construct(
SourceTree $tree,
BackwardSlicer $slicer,
SliceExecutor $executor,
ExpressionEvaluator $expressions,
EntryBinder $binder,
EvaluationBudget $budget,
?FreeNames $names = null,
)Wires the deriver to the source and the evaluator it reads values with.
Parameters
$tree | SourceTree | |
$slicer | BackwardSlicer | |
$executor | SliceExecutor | |
$expressions | ExpressionEvaluator | |
$binder | EntryBinder | |
$budget | EvaluationBudget | |
$names | ?FreeNames |
public function binder(): EntryBinderWhat binds the names a path still needs at the start of its body.
Returns
Test cases 1
Called from 2
public function evaluator(): ExpressionEvaluatorThe evaluator values are read with.
Returns
Test cases 1
public function solve(Node $point, list<Expr> $goals, int $depth = 0): list<Solution>Every way the expressions can be at the point, each with one value per expression.
Parameters
$point | Node | |
$goals | list<Expr> | |
$depth | int |
Returns
list<Solution>Test cases 1
Called from 6
- method-call SqlCatalog\Core\Analysis\Derivation\Deriver::solveUnlessSpent() packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:201
- method-call SqlCatalog\Core\Analysis\Derivation\EntryBinder::fromCallers() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:250
- method-call SqlCatalog\Core\Analysis\Interpreter::visit() packages/sql-catalog/src/Core/Analysis/Interpreter.php:232
- method-call SqlCatalog\Core\Analysis\Interpreter::visit() packages/sql-catalog/src/Core/Analysis/Interpreter.php:238
- method-call SqlCatalog\Core\Analysis\Interpreter::receiverOf() packages/sql-catalog/src/Core/Analysis/Interpreter.php:276
- method-call SqlCatalog\Core\Analysis\Model\ModelQueries::solve() packages/sql-catalog/src/Core/Analysis/Model/ModelQueries.php:31
Calls 8
- function-call
spl_object_idline 108 - function-call
implodeline 108 - function-call
array_mapline 108 - method-call Deriver::run() line 113
- method-call BackwardSlicer::sliceFrom() line 113
- method-call FreeNames::of() line 113
- method-call Deriver::scopeOf() line 113
- method-call EvaluationBudget::isExhausted() line 114
public function solveAtExits(FunctionLike $body, list<Expr> $goals, int $depth): list<Solution>Every way the expressions can be when a body finishes, by returning or by running off its end.
Parameters
$body | FunctionLike | |
$goals | list<Expr> | Expressions that read nothing but what the body leaves behind, such as a property of `$this` |
$depth | int |
Returns
list<Solution>Called from 1
Calls 18
- function-call
spl_object_idline 131 - function-call
implodeline 131 - function-call
array_mapline 131 - method-call FreeNames::of() line 136
- method-call BackwardSlicer::sliceFromEnd() line 137
- method-call
NodeFinder::findInstanceOf()line 138 - new
NodeFinderline 138 - method-call
FunctionLike::getStmts()line 138 - class-const
Return_::class()line 138 - method-call SourceTree::bodyOf() line 139
- function-call
array_mergeline 140 - method-call BackwardSlicer::sliceFrom() line 140
- method-call Deriver::nameOf() line 143
- new FunctionScope line 144
- method-call SourceTree::fileOf() line 144
- method-call Deriver::classOf() line 144
- method-call Deriver::run() line 145
- method-call EvaluationBudget::isExhausted() line 146
public function run(
list<Arrival> $arrivals,
list<Expr> $goals,
FunctionScope $scope,
int $depth,
): list<Solution>The paths that arrived at a body's start, run forward along every way in, with the expressions read at their end.
Parameters
$arrivals | list<Arrival> | |
$goals | list<Expr> | |
$scope | FunctionScope | |
$depth | int |
Returns
list<Solution>Called from 2
Calls 11
- method-call SliceExecutor::affordableRuns() line 165
- method-call EntryBinder::affordable() line 166
- method-call EntryBinder::bindings() line 166
- function-call
maxline 167 - function-call
intdivline 167 - function-call
countline 167 - method-call SliceExecutor::run() line 169
- function-call
array_mapline 171 - method-call ExpressionEvaluator::evaluate() line 171
- new Solution line 172
- method-call Deriver::bounded() line 182
public function spent(): boolWhether the budget is spent, so no further search should start.
Returns
boolCalled from 1
Calls 1
- method-call EvaluationBudget::isExhausted() line 190
public function solveUnlessSpent(Node $point, list<Expr> $goals, int $depth): list<Solution>The same as solving, or nothing at all once the budget is spent.
Parameters
$point | Node | |
$goals | list<Expr> | |
$depth | int |
Returns
list<Solution>Called from 1
Calls 2
- method-call EvaluationBudget::isExhausted() line 201
- method-call Deriver::solve() line 201
public function scopeOf(Node $point): FunctionScopeThe scope a point is evaluated in: its file, its function and its class.
Parameters
$point | Node |
Returns
Called from 2
Calls 6
- method-call SourceTree::bodyOf() line 227
- class-const FunctionScope::MAIN() line 231
- method-call Deriver::nameOf() line 231
- new FunctionScope line 233
- method-call SourceTree::fileOf() line 233
- method-call Deriver::classOf() line 233
public function classOf(Node $node): ?stringThe class a node is written in, or null when it is written in none.
Parameters
$node | Node |
Returns
?stringCalled from 10
- method-call SqlCatalog\Core\Analysis\Derivation\Callers::of() packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:70
- method-call SqlCatalog\Core\Analysis\Derivation\Callers::instantiations() packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:126
- method-call SqlCatalog\Core\Analysis\Derivation\Callers::reaches() packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:183
- method-call SqlCatalog\Core\Analysis\Derivation\Callers::staticTarget() packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:216
- method-call SqlCatalog\Core\Analysis\Derivation\Callers::staticTarget() packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:217
- method-call SqlCatalog\Core\Analysis\Derivation\Deriver::solveAtExits() packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:144
- method-call SqlCatalog\Core\Analysis\Derivation\Deriver::scopeOf() packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:233
- method-call SqlCatalog\Core\Analysis\Derivation\Deriver::nameOf() packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:258
- method-call SqlCatalog\Core\Analysis\Derivation\Deriver::nameOf() packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:264
- method-call SqlCatalog\Core\Analysis\Derivation\EntryBinder::bindings() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:107
Calls 1
- method-call
Node::getAttribute()line 241
public function nameOf(FunctionLike $body): stringThe name a body is reported under.
Parameters
$body | FunctionLike |
Returns
stringCalled from 3
- method-call SqlCatalog\Core\Analysis\Derivation\Deriver::solveAtExits() packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:143
- method-call SqlCatalog\Core\Analysis\Derivation\Deriver::scopeOf() packages/sql-catalog/src/Core/Analysis/Derivation/Deriver.php:231
- method-call SqlCatalog\Core\Analysis\Derivation\EntryBinder::parameterBindings() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:192
Calls 2
- method-call Deriver::classOf() line 258
- class-const FunctionScope::MAIN() line 264
Private surface 8§
Implementation details, listed for orientation only.
private SourceTree $treeprivate BackwardSlicer $slicerprivate SliceExecutor $executorprivate FreeNames $namesprivate EvaluationBudget $budgetprivate ExpressionEvaluator $expressionsprivate EntryBinder $binderprivate array<string, list<Solution>> $remembered = []Test cases 31§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
DeriverTest::testBinderIsTheEntryBinderTheDeriverWasWiredWithcallsDeriverTest::testBoundedKeepsSolutionsWithinTheLimitAsTheyArecallsDeriverTest::testBoundedMarksSolutionsBeyondTheLimitTruncatedcallsDeriverTest::testEvaluatorIsTheEvaluatorTheDeriverWasWiredWithcallsDeriverTest::testRunKeepsNoMoreSolutionsThanTheLimitcallsDeriverTest::testSolveMarksEverySolutionTruncatedWhenCallsWereLeftOutcallsDeriverTest::testSolveReadsWhatTheGoalsNeedWithTheNamesItWasGivencalls
Other tests reaching this symbol 24
CatalogCommandTestcallsCallEvaluatorTestcallsConstantReaderTestcallsCalleeReturnsTestcallsCallersTest::testOfListsEveryCallerWithoutStoppingAtTheCallerLimitcallsEntryBinderTest::testWithPropertyKeepsNoMoreWaysInThanTheSolutionLimitcallsCallbackEffectsTestcallsPropertyWritesTest::testValuesOfCollectsWhatEveryWriterLeavescallsPropertyWritesTest::testValuesOfSkipsTheWritersOnceTheBudgetIsSpentcallsSliceExecutorTestcallsExpressionEvaluatorTestcallsRegistryTestcallsInterpreterTestcallsModelQueriesTestcallsReferenceEvaluatorTestcallsCallContextTestcallsQueryModelInterfaceTestcallsBuilderCallsTestcallsBuilderQueriesTestcallsCallbackModelTestcallsCallModelTestcallsAnalyzerTestcallsJsonReporterTestcallsTextReporterTestcalls
Relations§
Instantiated in 1
Method calls 18
- method-call SqlCatalog\Core\Analysis\Derivation\Callers::of() packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:70
- method-call SqlCatalog\Core\Analysis\Derivation\Callers::instantiations() packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:126
- method-call SqlCatalog\Core\Analysis\Derivation\Callers::reaches() packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:183
- method-call SqlCatalog\Core\Analysis\Derivation\Callers::reaches() packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:188
- method-call SqlCatalog\Core\Analysis\Derivation\Callers::staticTarget() packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:216
- method-call SqlCatalog\Core\Analysis\Derivation\Callers::staticTarget() packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:217
- method-call SqlCatalog\Core\Analysis\Derivation\EntryBinder::bindings() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:107
- method-call SqlCatalog\Core\Analysis\Derivation\EntryBinder::parameterBindings() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:192
- method-call SqlCatalog\Core\Analysis\Derivation\EntryBinder::fromCallers() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:250
- method-call SqlCatalog\Core\Analysis\Derivation\PropertyWrites::valuesOf() packages/sql-catalog/src/Core/Analysis/Derivation/PropertyWrites.php:75
- method-call SqlCatalog\Core\Analysis\Derivation\PropertyWrites::valuesOf() packages/sql-catalog/src/Core/Analysis/Derivation/PropertyWrites.php:76
- method-call SqlCatalog\Core\Analysis\Derivation\PropertyWrites::valuesOf() packages/sql-catalog/src/Core/Analysis/Derivation/PropertyWrites.php:82
- method-call SqlCatalog\Core\Analysis\Derivation\PropertyWrites::valuesOf() packages/sql-catalog/src/Core/Analysis/Derivation/PropertyWrites.php:86
- method-call SqlCatalog\Core\Analysis\Interpreter::visit() packages/sql-catalog/src/Core/Analysis/Interpreter.php:205
- method-call SqlCatalog\Core\Analysis\Interpreter::visit() packages/sql-catalog/src/Core/Analysis/Interpreter.php:232
- method-call SqlCatalog\Core\Analysis\Interpreter::visit() packages/sql-catalog/src/Core/Analysis/Interpreter.php:238
- method-call SqlCatalog\Core\Analysis\Interpreter::receiverOf() packages/sql-catalog/src/Core/Analysis/Interpreter.php:276
- method-call SqlCatalog\Core\Analysis\Model\ModelQueries::solve() packages/sql-catalog/src/Core/Analysis/Model/ModelQueries.php:31
Constant reads 4
- class-const SqlCatalog\Core\Analysis\Derivation\EntryBinder::withProperty() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:147
- class-const SqlCatalog\Core\Analysis\Derivation\EntryBinder::withProperty() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:153
- class-const SqlCatalog\Core\Analysis\Derivation\EntryBinder::fromCallers() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:241
- class-const SqlCatalog\Core\Analysis\Derivation\EntryBinder::fromCallers() packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:243
Type declarations 15
- type SqlCatalog\Core\Analysis\Derivation\Callers packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:62
- type SqlCatalog\Core\Analysis\Derivation\Callers packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:119
- type SqlCatalog\Core\Analysis\Derivation\Callers packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:164
- type SqlCatalog\Core\Analysis\Derivation\Callers packages/sql-catalog/src/Core/Analysis/Derivation/Callers.php:208
- type SqlCatalog\Core\Analysis\Derivation\EntryBinder packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:104
- type SqlCatalog\Core\Analysis\Derivation\EntryBinder packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:162
- type SqlCatalog\Core\Analysis\Derivation\EntryBinder packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:189
- type SqlCatalog\Core\Analysis\Derivation\EntryBinder packages/sql-catalog/src/Core/Analysis/Derivation/EntryBinder.php:239
- type SqlCatalog\Core\Analysis\Derivation\PropertyWrites packages/sql-catalog/src/Core/Analysis/Derivation/PropertyWrites.php:65
- type SqlCatalog\Core\Analysis\Interpreter packages/sql-catalog/src/Core/Analysis/Interpreter.php:144
- type SqlCatalog\Core\Analysis\Interpreter packages/sql-catalog/src/Core/Analysis/Interpreter.php:200
- type SqlCatalog\Core\Analysis\Interpreter packages/sql-catalog/src/Core/Analysis/Interpreter.php:246
- type SqlCatalog\Core\Analysis\Interpreter packages/sql-catalog/src/Core/Analysis/Interpreter.php:273
- type SqlCatalog\Core\Analysis\Interpreter packages/sql-catalog/src/Core/Analysis/Interpreter.php:290
- type SqlCatalog\Core\Analysis\Model\ModelQueries packages/sql-catalog/src/Core/Analysis/Model/ModelQueries.php:25