ConstantArbitrary
Rasuvaeff\PropertyTesting\Arbitrary\ConstantArbitrary
Class — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2
Implements: Enumerable, ArbitraryInterface
Type parameters:
TValue of mixed = mixed
Always produces the same fixed value. Useful as a building block for composite generators (e.g. a record field that is held constant) and for pinning one parameter while others vary.
There is nothing smaller than a constant, so it does not shrink.
Constructor
__construct(
\Arbitrary\TValue $value,
)| Parameter | Type | Default | Description |
|---|---|---|---|
$value | Arbitrary\TValue | required |
Methods
generate()
generate(Random $random): ShrinkableProduce 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()
domainSize(): intHow many distinct values enumerate() walks, or null when the domain is not finite in this configuration. Saturates at PHP_INT_MAX rather than overflowing — a budget compares against it, nothing computes with it. An upper bound is acceptable where the exact count is not known without walking (a filter over a finite source).
Documentation inherited from Enumerable.
enumerate()
enumerate(): iterableEvery value of the domain, once each, as a shrinkable node with the same tree generate() would give it, in a fixed order that does not depend on any seed. Only meaningful when domainSize() is not null; an implementation may throw otherwise.
Documentation inherited from Enumerable.