Skip to content

Examples ​

Every package ships its own examples/, runnable after composer install via the composer:2 Docker image (no PHP/Composer needed on the host).

property-testing-core ​

ScriptShowsNeeds server?
basic.phpA property that holds, one that is falsified, and how the counterexample is shrunk by descending the Shrinkable tree (uses generators directly, no runner)No
generators.phpsample, boundary bias, uuid, datetime, dictOf, record, and dependent generation with flatMap (uses generators directly, no runner)No
standalone_runner.phpDriving the framework-agnostic engine directly: a hand-built PropertyDefinition, CallableTrialExecutor, structured PropertyResult inspection, and the run knobs — ShrinkMode::Off, path replay, the DistributionReport a listener reads off PropertyFinished, and phases: [Phase::Examples, Phase::Corpus] as a fast gateNo
for_class.phpGen::forClass(): the same shape with and without psalm annotations, an override narrowing one parameter, and a validating constructor both ways (throwing by default, skipInvalid: true discarding)No
swarm.phpSwarm testing: how often a case avoids an operation entirely with a uniform alphabet versus a per-case subset, Gen::swarm() over a choice generator and over Gen::commands(), and a shrink descent that stays inside its subsetNo
custom_listeners.phpCustom observers over the engine's event model: a console reporter narrating the shrink descent and a telemetry collector aggregating run counts, timings and labels — pure PropertyListener implementations, no engine changesNo
case-studies/regex-anchor.phpCookbook case study: a $-anchored identifier validator accepting a trailing newlineNo
case-studies/saturating-minus.phpCookbook case study: subtraction producing a negative duration instead of saturating at zeroNo
case-studies/backoff-cap.phpCookbook case study: jitter added after the cap was applied, pushing the delay past itNo
case-studies/hash-bucketing.phpCookbook case study: a rollout hash salted with the percentage, breaking monotonicityNo
case-studies/faker-vs-property.phpCookbook comparison: the same UTF-8 truncation bug found with realistic (Faker-shaped) data and with shrinkable data — both falsify, only one minimisesNo

property-testing-testo ​

ScriptShowsNeeds server?
property_test.phpCanonical #[Property] usage as a real Testo test case, including an in-body dependent draw with Gen::draw() and auto: true deriving generators from the signatureNo
state_machine.phpStateful / model-based testing: a Command interface, Gen::commands(), and StateMachine::check() driving command sequences against a stackNo

property-testing-phpunit ​

ExampleShowsNeeds server?
SortPropertyTest.phpA complete property-based PHPUnit TestCase: the PropertyTesting trait, the fluent forAll()->runs()->check() chain, Classify::when() distribution labels, an Assume::that() discard, and auto() deriving generators from the closure — four properties over a plain sortNo