Skip to content

NullableArbitrary ​

Rasuvaeff\PropertyTesting\Arbitrary\NullableArbitrary

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

Implements: Enumerable, ArbitraryInterface

Wraps another arbitrary and additionally yields null with roughly even odds.

Shrinking prefers null over descending into the inner value's tree.

Constructor ​

php
__construct(
    ArbitraryInterface $inner,
)
ParameterTypeDefaultDescription
$innerArbitraryInterfacerequired

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

One more than the inner domain, when there is one to count.

enumerate() ​

php
enumerate(): iterable

Null first, then the inner domain in its own order.

Throws:

  • LogicException — When the source has no finite domain (\Rasuvaeff\PropertyTesting\Arbitrary\domainSize() is null).