PHPackages                             fr3on/php-hypothesis - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. fr3on/php-hypothesis

ActiveLibrary[Testing &amp; Quality](/categories/testing)

fr3on/php-hypothesis
====================

Smarter property-based testing for PHP 8.4+

0.0.1(3mo ago)1220MITPHPPHP &gt;=8.4CI passing

Since Apr 13Pushed 3mo agoCompare

[ Source](https://github.com/fr3on/php-hypothesis)[ Packagist](https://packagist.org/packages/fr3on/php-hypothesis)[ RSS](/packages/fr3on-php-hypothesis/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

php-hypothesis
==============

[](#php-hypothesis)

[![CI](https://github.com/fr3on/php-hypothesis/actions/workflows/ci.yml/badge.svg)](https://github.com/fr3on/php-hypothesis/actions/workflows/ci.yml)[![License](https://camo.githubusercontent.com/2f4a75234c05abc1907fe8eb2e90dcf6168465a6fb957d999221e749500b2cf3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6672336f6e2f7068702d6879706f746865736973)](https://github.com/fr3on/php-hypothesis/blob/main/LICENSE)

Property-based testing for PHP 8.4+, inspired by the Python `Hypothesis` library.

Features
--------

[](#features)

- **Property-Based Testing**: Define properties that should always be true, and let the library find counter-examples.
- **Smart Shrinking**: When a failure is found, the library automatically shrinks the input to the smallest possible failing case.
- **PHP 8.4+ Attributes**: Use the `#[Given]` attribute for clean, declarative test definitions.
- **PHPUnit Integration**: Seamlessly integrates with PHPUnit 11+.
- **Zero Runtime Dependencies**: Lightweight and fast.

Installation
------------

[](#installation)

```
composer require fr3on/php-hypothesis
```

Quick Start
-----------

[](#quick-start)

```
use Fr3on\Hypothesis\PHPUnit\PropertyTestCase;
use Fr3on\Hypothesis\Attribute\Given;
use Fr3on\Hypothesis\Shape\ListShape;
use Fr3on\Hypothesis\Shape\IntegerShape;

class SortingTest extends PropertyTestCase
{
    #[Given(new ListShape(new IntegerShape()))]
    public function prop_sort_is_idempotent(array $list): void
    {
        $sorted = $list;
        sort($sorted);

        $doubleSorted = $sorted;
        sort($doubleSorted);

        $this->assertSame($sorted, $doubleSorted);
    }
}
```

How it Works
------------

[](#how-it-works)

1. **Generation**: The library generates random data based on the "Shapes" you define (Integer, String, List, etc.).
2. **Execution**: Your test runs multiple times (default 100) with different inputs.
3. **Shrinking**: If a failure occurs, the library iteratively simplifies the input to find the "minimal reproducible case".
4. **Result**: You get a clear report of exactly what caused the property to fail.

License
-------

[](#license)

MIT

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance81

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

102d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/205356416?v=4)[fr3onv](/maintainers/fr3onv)[@fr3onv](https://github.com/fr3onv)

---

Top Contributors

[![fr3on](https://avatars.githubusercontent.com/u/26393383?v=4)](https://github.com/fr3on "fr3on (3 commits)")

---

Tags

hypothesisphpphpunitproperty-based-testingqatestingtestingphpunitqaphp84property based testinghypothesis

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fr3on-php-hypothesis/health.svg)

```
[![Health](https://phpackages.com/badges/fr3on-php-hypothesis/health.svg)](https://phpackages.com/packages/fr3on-php-hypothesis)
```

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k955.1M159.1k](/packages/phpunit-phpunit)[brianium/paratest

Parallel testing for PHP

2.5k136.1M1.0k](/packages/brianium-paratest)[phpmetrics/phpmetrics

Static analyzer tool for PHP : Coupling, Cyclomatic complexity, Maintainability Index, Halstead's metrics... and more !

2.6k15.4M376](/packages/phpmetrics-phpmetrics)[codedungeon/phpunit-result-printer

PHPUnit Pretty Result Printer

1.2k9.0M414](/packages/codedungeon-phpunit-result-printer)[dg/bypass-finals

Removes final keyword from source code on-the-fly and allows mocking of final methods and classes

57329.2M623](/packages/dg-bypass-finals)[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69619.8M652](/packages/spatie-phpunit-snapshot-assertions)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
