final class Deriver
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

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 = 12

How many callers of one body are asked, before the rest are left out and the search marked as cut short.

public const MAX_SOLUTIONS = 32

How 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

Calls 1
public function evaluator(): ExpressionEvaluator

The evaluator values are read with.

Test cases 1
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

$bodyFunctionLike
$goalslist<Expr>Expressions that read nothing but what the body leaves behind, such as a property of `$this`
$depthint

Returns

list<Solution>
Called from 1
Calls 18
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

$arrivalslist<Arrival>
$goalslist<Expr>
$scopeFunctionScope
$depthint

Returns

list<Solution>
Called from 2
Calls 11
public function spent(): bool

Whether the budget is spent, so no further search should start.

Returns

bool
Called from 1
Calls 1
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

$pointNode
$goalslist<Expr>
$depthint

Returns

list<Solution>
Called from 1
Calls 2
public function bounded(list<Solution> $solutions): list<Solution>

The solutions, cut to the limit and marked when they had to be.

Parameters

$solutionslist<Solution>

Returns

list<Solution>
Called from 1
Calls 5
public function classOf(Node $node): ?string

The class a node is written in, or null when it is written in none.

Parameters

$nodeNode

Returns

?string
Called from 10
Calls 1
  • method-call Node::getAttribute() line 241

Private surface 8§

Implementation details, listed for orientation only.

private SourceTree $tree
private BackwardSlicer $slicer
private SliceExecutor $executor
private FreeNames $names
private EvaluationBudget $budget
private ExpressionEvaluator $expressions
private EntryBinder $binder
private 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
Other tests reaching this symbol 24

Relations§

Instantiated in 1
Method calls 18
Constant reads 4
Type declarations 15