Skip to content

RecordArbitrary

Rasuvaeff\PropertyTesting\Arbitrary\RecordArbitrary

ClassPackage: property-testing-coreSourceVersion: v0.1.0-12-g86ead85

Implements: 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.