Target
Rasuvaeff\PropertyTesting\Target
Class — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2
Reports a score the engine should push toward an extreme: a delay, a recursion depth, a queue length, a distance from a boundary — whatever number gets larger (or smaller) as the input gets closer to where the bug lives. With Runner\PropertyConfig::$searchRuns on, the run spends a search phase after the random one climbing that score: the best-scoring inputs are kept in a pool and mutated one parameter at a time, and every improvement is reported as a Event\TargetImproved event.
#[Property(runs: 200, searchRuns: 100)]
public function backoffStaysUnderCap(int $base, int $attempt): void
{
$delay = (new Backoff($base))->delayMs($attempt);
Target::maximize('delay', $delay);
Assert::true($delay <= 60_000);
}A label's direction is fixed for the whole property: maximising and minimising the same label is a configuration error, reported at the call. So is a score that is not finite. Without a search phase the calls cost one array write per run and change nothing.
State is per-run and process-local, like Classify: the runner clears it before each run and drains it after. Property runs are sequential, so the static buffer is never shared concurrently.
Methods
maximize()
static maximize(string $label, int|float $score): voidPush $label toward larger scores.
$label— The score's name; one direction per label for the whole property.$score— This run's score; must be finite.
minimize()
static minimize(string $label, int|float $score): voidPush $label toward smaller scores.
$label— The score's name; one direction per label for the whole property.$score— This run's score; must be finite.
beginRun()
static beginRun(): voidClear the scores of the previous run.
flushRun()
static flushRun(): arrayReturn the scores of the current run and clear them.
directions()
static directions(): arrayThe directions registered so far, by label, in first-reported order.
flushDirections()
static flushDirections(): arrayReturn the directions registered during the property and clear them.