Shrinkable
Rasuvaeff\PropertyTesting\Shrinkable
Class — Package: property-testing-core — Source — Version: v0.1.0-12-g86ead85
Type parameters:
TValue of mixed = mixed The type of the carried value
A generated value together with a lazy tree of progressively "smaller" variants of it — the unit of integrated shrinking.
Every ArbitraryInterface::generate() call returns one of these. The property runner reads $value, and when the property fails it walks shrinks(): each child is a smaller candidate that carries its own subtree, so accepting a candidate immediately provides the next round of even smaller candidates. Because the tree is built at generation time, a transformed arbitrary (Gen::map(), Gen::flatMap()) shrinks in the source domain and re-applies the transformation — no inverse function is ever needed.
Children are produced lazily (the closure runs only when the runner asks), so building a node costs nothing until shrinking actually happens.
Constructor
__construct(
\TValue $value,
callable $shrinks,
)| Parameter | Type | Default | Description |
|---|---|---|---|
$value | TValue | required | |
$shrinks | callable | required |
Methods
leaf()
static leaf(\T $value): selfA value with no smaller variants (terminal node).
of()
static of(\T $value, callable $shrinks): selfA value with lazily-computed smaller variants, ordered most aggressive first (typically toward a zero/empty/identity element).
shrinks()
shrinks(): iterableThe smaller variants of this value, each with its own subtree.
map()
map(callable $map): selfTransform the whole tree through a pure function: the value and, lazily, every shrink candidate. This is what makes Gen::map() shrink.