Skip to content

IntArbitrary ​

Rasuvaeff\PropertyTesting\Arbitrary\IntArbitrary

Class — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2

Implements: Enumerable, ArbitraryInterface

Generates integers within an inclusive range and shrinks them toward zero (clamped into the range, so the target of a zero-free range is its nearest bound).

Generation is biased: roughly one draw in Arbitrary\BIAS_DENOMINATOR returns an in-range boundary value (0, ±1, min, max) instead of a uniform one, because bugs cluster at edges.

The shrink tree halves the distance to the target: the target itself first, then candidates progressively closer to the failing value, each with its own subtree toward the same target — a binary search for the minimal failing integer.

Constructor ​

php
__construct(
    int $min = PHP_INT_MIN,
    int $max = PHP_INT_MAX,
)
ParameterTypeDefaultDescription
$minintPHP_INT_MIN
$maxintPHP_INT_MAX

Methods ​

generate() ​

php
generate(Random $random): Shrinkable

Produce one random value from this arbitrary's space, together with its shrink tree. Candidates must be ordered most aggressive first (typically toward a zero/empty/identity element) and every branch of the tree must be finite, so shrinking terminates.

Documentation inherited from ArbitraryInterface.

domainSize() ​

php
domainSize(): ?int

Saturates: a range wider than PHP_INT_MAX values (the full int range above all) reports PHP_INT_MAX, which no budget accepts.

enumerate() ​

php
enumerate(): iterable

Ascending from the minimum.