Classify
Rasuvaeff\PropertyTesting\Classify
Class — Source
Records distribution labels for the current property run so the runner can report how often each case occurred. Use it to confirm a property is not passing vacuously — that the generators actually exercise the interesting inputs.
#[Property(runs: 500)]
public function holds(int $n): void
{
Classify::when($n === 0, 'zero');
Classify::when($n < 0, 'negative');
Classify::label($n % 2 === 0 ? 'even' : 'odd');
// ... assertions ...
}After a fully passing property the runner prints the share of runs that hit each label. A label recorded several times within one run still counts once for that run.
State is per-run and process-local: the runner clears it before each run via beginRun() and drains it via flushRun(). Property runs are sequential, so the static buffer is never shared concurrently.
Methods
label()
static label(string $label): voidRecord $label for the current run.
when()
static when(bool $condition, string $label): voidRecord $label for the current run only when $condition holds.
cover()
static cover(
bool $condition,
string $label,
float $minPercent,
): voidLike when(), but additionally REQUIRES the label to occur in at least $minPercent of the property's passing runs. When the requirement is not met the property fails with a CoverageViolationException even though every run passed — turning "the distribution looks wrong" from a printed hint into a CI failure.
Classify::cover($n % 2 === 0, 'even', 30.0);beginRun()
static beginRun(): voidClear the labels buffered for the current run.
flushRun()
static flushRun(): arrayReturn the labels recorded during the current run and clear the buffer.
flushRequirements()
static flushRequirements(): arrayReturn the coverage requirements registered during the property and clear them. The runner drains this once after the run loop (and defensively before it, in case a previous property aborted mid-flight).