RuleStep
Rasuvaeff\PropertyTesting\StateMachine\RuleStep
Class — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2
Implements: StateMachine\Command, Stringable
One step of a rule-based sequence: a Rule method and the arguments drawn for it. It is the Command the engine's sequence generation and shrinking work on, so a rule-based machine gets the same drop-and-simplify descent a hand-written command sequence does.
The model threaded through StateMachine\StateMachine::check() is the machine object itself: at generation time there is no machine yet and every step is applicable (the model is null), at run time the guard decides. The step's body is the rule method — its exception is the failed postcondition — followed by every invariant.
Constructor
__construct(
non-empty-string $rule,
array<string,mixed> $arguments,
?non-empty-string $precondition = NULL,
list<non-empty-string> $invariants = [],
)| Parameter | Type | Default | Description |
|---|---|---|---|
$rule | non-empty-string | required | The rule method. |
$arguments | array<string,mixed> | required | By parameter name. |
$precondition | ?non-empty-string | NULL | The guard method, when the rule has one. |
$invariants | list<non-empty-string> | [] | The invariant methods, run after the rule. |
Methods
preCondition()
preCondition(mixed $model): boolTrue before a machine exists (generation), the guard's answer once it does.
$model— The machine, or null at generation time.
nextState()
nextState(mixed $model): mixedThe machine itself: its state is its own fields, advanced by run().
$model— The machine, or null at generation time.
run()
run(mixed $model, mixed $system): mixedRuns the rule, then every invariant, against $system — the machine.
$model— The machine, unused: the step acts on $system, which is the same object.$system— The machine.
Throws:
LogicException— When $system is not an object.
postCondition()
postCondition(mixed $model, mixed $result): boolAlways true: the rule's exception is the failed postcondition.
$model— The machine.$result— WhatStateMachine\run() returned — null.
__toString()
__toString(): stringThe step as a call: rule(name: value, ...).