PHPackages                             patchlevel/event-sourcing-phpstan-extension - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. patchlevel/event-sourcing-phpstan-extension

ActivePhpstan-extension[Utility &amp; Helpers](/categories/utility)

patchlevel/event-sourcing-phpstan-extension
===========================================

PHPStan that understands your aggregates and catches event sourcing mistakes before runtime

1.3.0(4w ago)158.2k↓59.3%[1 issues](https://github.com/patchlevel/event-sourcing-phpstan-extension/issues)MITPHPPHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Aug 13Pushed 2w ago2 watchersCompare

[ Source](https://github.com/patchlevel/event-sourcing-phpstan-extension)[ Packagist](https://packagist.org/packages/patchlevel/event-sourcing-phpstan-extension)[ Docs](https://patchlevel.dev/docs/event-sourcing-phpstan-extension/latest)[ RSS](/packages/patchlevel-event-sourcing-phpstan-extension/feed)WikiDiscussions 1.4.x Synced 1w ago

READMEChangelog (4)Dependencies (16)Versions (15)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/41831f0b9dca8dce09e401bd6ca6feb37453086ceb194984ed28656a44cd1ddc/68747470733a2f2f706f7365722e707567782e6f72672f70617463686c6576656c2f6576656e742d736f757263696e672d7068707374616e2d657874656e73696f6e2f76)](//packagist.org/packages/patchlevel/event-sourcing-phpstan-extension)[![License](https://camo.githubusercontent.com/3094614018c0a260abc1481df34d6887fd219a20bf0421c32bb1596fe94c205d/68747470733a2f2f706f7365722e707567782e6f72672f70617463686c6576656c2f6576656e742d736f757263696e672d7068707374616e2d657874656e73696f6e2f6c6963656e7365)](//packagist.org/packages/patchlevel/event-sourcing-phpstan-extension)

event-sourcing-phpstan-extension
================================

[](#event-sourcing-phpstan-extension)

"PHPStan that understands your aggregates and catches event sourcing mistakes before runtime."

Features
--------

[](#features)

- [Property initialization](https://patchlevel.dev/docs/event-sourcing-phpstan-extension/latest/getting-started#property-initialization) for aggregate roots and child aggregates, so PHPStan does not report false uninitialized property errors.
- [Unused properties](https://patchlevel.dev/docs/event-sourcing-phpstan-extension/latest/getting-started#unused-properties) are reported when no apply method writes them, because such a property can never receive state from an event.
- [Write only properties](https://patchlevel.dev/docs/event-sourcing-phpstan-extension/latest/getting-started#write-only-properties) are reported when apply methods store state that is never read, because state that is not used to check invariants belongs in a projection.
- [Recording in apply methods](https://patchlevel.dev/docs/event-sourcing-phpstan-extension/latest/getting-started#recording-in-apply-methods) is reported as an error, because recording events while replaying them leads to duplicated events.
- [Writing state outside apply methods](https://patchlevel.dev/docs/event-sourcing-phpstan-extension/latest/getting-started#writing-state-outside-apply-methods) is reported as an error, because state that is not derived from an event is lost when the aggregate is reloaded.

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

[](#installation)

```
composer require --dev patchlevel/event-sourcing-phpstan-extension
```

If you use [phpstan/extension-installer](https://github.com/phpstan/extension-installer), the extension is registered automatically. Otherwise register it in your `phpstan.neon`:

```
includes:
    - vendor/patchlevel/event-sourcing-phpstan-extension/extension.neon
```

Documentation
-------------

[](#documentation)

- Latest [Docs](https://patchlevel.dev/docs/event-sourcing-phpstan-extension/latest)
- Related [Blog](https://patchlevel.dev/blog)

Integration
-----------

[](#integration)

- [patchlevel/event-sourcing](https://github.com/patchlevel/event-sourcing)

Contributing
------------

[](#contributing)

We are open to contributions as long as they are in line with our [BC-Policy](https://patchlevel.dev/our-backward-compatibility-promise).

Also note that the `composer.lock` is always generated with the newest supported PHP version as this is the version our tools run in the CI.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance75

Regular maintenance activity

Popularity33

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 79.2% 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

Every ~40 days

Recently: every ~27 days

Total

10

Last Release

10d ago

Major Versions

1.1.x-dev → 2.0.x-dev2025-12-04

PHP version history (2 changes)1.0.0PHP ~8.1 || ~8.2 || ~8.3 || 8.4

1.1.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/470138?v=4)[David Badura](/maintainers/DavidBadura)[@DavidBadura](https://github.com/DavidBadura)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (152 commits)")[![DanielBadura](https://avatars.githubusercontent.com/u/2017762?v=4)](https://github.com/DanielBadura "DanielBadura (28 commits)")[![DavidBadura](https://avatars.githubusercontent.com/u/470138?v=4)](https://github.com/DavidBadura "DavidBadura (12 commits)")

---

Tags

PHPStanstatic analysisevent sourcingpatchlevelaggregate

### Embed Badge

![Health badge](/badges/patchlevel-event-sourcing-phpstan-extension/health.svg)

```
[![Health](https://phpackages.com/badges/patchlevel-event-sourcing-phpstan-extension/health.svg)](https://phpackages.com/packages/patchlevel-event-sourcing-phpstan-extension)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.5k60.6M10.5k](/packages/larastan-larastan)[deptrac/deptrac

Deptrac is a static code analysis tool that helps to enforce rules for dependencies between software layers.

3.0k9.8M294](/packages/deptrac-deptrac)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

5014.2M111](/packages/shipmonk-dead-code-detector)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67475.0M1.6k](/packages/phpstan-phpstan-doctrine)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79378.2M2.5k](/packages/phpstan-phpstan-symfony)[php-stubs/wordpress-stubs

WordPress function and class declaration stubs for static analysis.

20117.1M490](/packages/php-stubs-wordpress-stubs)

PHPackages © 2026

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