Skip to content

RecordArbitrary ​

Rasuvaeff\PropertyTesting\Arbitrary\RecordArbitrary

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

Implements: Enumerable, ArbitraryInterface

Fixed-shape associative array: produces a map with one value per named field, each drawn from that field's arbitrary. Useful for generating DTO-shaped payloads where every key is known up front (the property receives the record as a single string-keyed array argument).

Shrinking keeps the key set fixed and shrinks one field at a time through that field's own shrink tree, so each value shrinks within its domain.

Constructor ​

php
__construct(
    array<string,\ArbitraryInterface> $shape,
)
ParameterTypeDefaultDescription
$shapearray<string,\ArbitraryInterface>requiredField name => arbitrary for that field.

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

The product of the fields' domains, when every field has one.

enumerate() ​

php
enumerate(): iterable

First field varying slowest.

Throws:

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