Random
Rasuvaeff\PropertyTesting\Random
Class — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2
Seedable, deterministic pseudo-random number generator.
Two instances created with the same seed produce identical sequences, which is what makes counterexamples reproducible. Backed by an object-scoped Mersenne Twister (MT19937) engine via ext-random's Random\Randomizer, so it is independent of PHP's global mt_rand state — important inside a test runner where other code may draw random numbers between runs.
It also carries the Runner\EdgeCases choice, because the generators that act on it already receive this and nothing else: threading a second parameter through every ArbitraryInterface would change a published signature to say something the source of randomness can say instead.
Constructor
__construct(
int $seed,
\Runner\EdgeCases $edgeCases = Rasuvaeff\PropertyTesting\Runner\EdgeCases::Mixin,
)| Parameter | Type | Default | Description |
|---|---|---|---|
$seed | int | required | The seed; two instances with the same one produce the same sequence. |
$edgeCases | Runner\EdgeCases | Rasuvaeff\PropertyTesting\Runner\EdgeCases::Mixin | Whether the numeric generators keep biasing toward boundary values. |
Methods
drawsEdgeCase()
drawsEdgeCase(int $denominator): boolWhether this draw should be an edge value rather than a uniform one.
$denominator— The odds: one draw in this many is an edge value.
The roll happens either way. Skipping it under Runner\EdgeCases::None would shift every later draw and make the same seed mean something else in the two modes; consuming it keeps them aligned, so switching the mode changes which values are edges and not the whole sequence.
int()
int(int $min, int $max): intUniform integer in the inclusive range [$min, $max].
float()
float(): floatUniform float in the half-open range [0.0, 1.0).
bytes()
bytes(int $length): stringRandom byte string of the given length (bytes in 0..255).