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

Runs the steps a path kept, in order, and reports the values they leave behind.

Only the assignments the call depends on are run, so the work is what the statement needs rather than what the body does. When an assignment leaves a variable with several possible values — a ternary, a call that returns one of several strings — the run splits there, one run per value, so every later use of the variable sees the same one. That is what stops ORDER BY $o, id $o from pairing an ascending first column with a descending second.

Keeping runs apart costs one evaluation of every later step per run, so how many are kept apart is what the budget can pay for along the path: a short path keeps a dozen, a body of several hundred assignments under a hundred conditionals keeps a few, and joins the rest value by value. A joined run still holds every value; what it gives up is knowing which values go together.

Constants§

public const MAX_RUNS = 12

How many runs are kept apart before the rest are joined.

public const STEP_COST = 8

How many expressions running one step is expected to evaluate, for sizing how many runs a path can afford.

Methods§

public function __construct(
    ?DeclaredGlobals $globals = null,
    ?TypeReader $types = null,
    ?ModifiedNames $modified = null,
    ?NodeText $text = null,
    ?EvaluationBudget $budget = null,
)

Wires the executor to what it needs to bind declarations.

Parameters

Calls 5
public function run(
    list<SliceStep> $steps,
    Environment $start,
    FunctionScope $scope,
    ExpressionEvaluator $expressions,
    bool $closing = false,
    int|null $limit = null,
): list<Environment>

The environments the steps leave behind, one per run.

A run that works out something on the way to a statement — what a callee returns, what a caller passes, what a property holds — stops when the search's budget is spent. The run that reads the statement itself goes on until the reading limit, so what was found along the way is not thrown away for want of the last few steps.

Parameters

$stepslist<SliceStep>The steps, in the order they run
$startEnvironment
$scopeFunctionScope
$expressionsExpressionEvaluator
$closingboolWhether this run reads the statement itself rather than something on the way to it
$limitint|nullHow many runs to keep apart, or null to size it from the budget

Returns

Test cases 31
Called from 4
Calls 9
public function abandon(
    list<SliceStep> $steps,
    list<Environment> $environments,
): list<Environment>

The environments with everything the steps not yet run would write left open.

Stopping partway must not report a variable as holding what it held before a later assignment the run never got to: that would be a wrong statement rather than an incomplete one. So every name a remaining step writes is left open, marked as stopped by the budget.

Parameters

$stepslist<SliceStep>
$environmentslist<Environment>

Returns

Test cases 2
Called from 1
Calls 4
public function apply(
    SliceStep $step,
    Environment $environment,
    FunctionScope $scope,
    ExpressionEvaluator $expressions,
    WeakMap<Node, int> $passes,
    WeakMap<Node, Domain> $iterables,
    int $limit = self::MAX_RUNS,
): list<Environment>

The environments one step leaves behind, starting from one environment.

Parameters

$stepSliceStep
$environmentEnvironment
$scopeFunctionScope
$expressionsExpressionEvaluator
$passesWeakMap<Node, int>How many passes each loop has started so far
$iterablesWeakMap<Node, Domain>What each loop went over, as read before its first pass
$limitint

Returns

Test cases 9
Called from 1
Calls 11
public function enterClosure(
    Closure|ArrowFunction $closure,
    list<string> $names,
    Environment $environment,
): void
public function declare(Global_|Static_|Unset_ $declaration, Environment $environment): void
public function iterate(
    Foreach_ $loop,
    Domain $iterable,
    int $pass,
    Environment $environment,
    FunctionScope $scope,
    ExpressionEvaluator $expressions,
): void

Binds a foreach's variables for one pass.

An array written out in full gives each pass its own element; anything else gives every pass whatever an element of it can be.

Parameters

$loopForeach_
$iterableDomain
$passint
$environmentEnvironment
$scopeFunctionScope
$expressionsExpressionEvaluator
Test cases 3
Called from 1
Calls 7
public function assign(
    Expr $assignment,
    Environment $environment,
    FunctionScope $scope,
    ExpressionEvaluator $expressions,
): void
public function split(
    Environment $environment,
    array<string, true> $names,
    int $limit = self::MAX_RUNS,
): list<Environment>

Private surface 5§

Implementation details, listed for orientation only.

private DeclaredGlobals $globals
private TypeReader $types
private ModifiedNames $modified
private NodeText $text
private EvaluationBudget $budget

Test cases 134§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 55
Other tests reaching this symbol 79

Relations§

Instantiated in 1
Method calls 4
Type declarations 5