Download Latest Version 2.2.2 source code.tar.gz (4.0 MB)
Email in envelope

Get an email when there's a new version of PHPStan

Home / 2.2.0
Name Modified Size InfoDownloads / Week
Parent folder
phpstan.phar 2026-05-28 27.0 MB
phpstan.phar.asc 2026-05-28 833 Bytes
2.2.0 source code.tar.gz 2026-05-28 4.0 MB
2.2.0 source code.zip 2026-05-28 4.0 MB
README.md 2026-05-28 3.7 kB
Totals: 5 Items   35.1 MB 1

Dive into details about this release on PHPStan's blog: PHPStan 2.2: Unsealed Array Shapes, Safer Array Keys, and More!. It explains all the changes and the motivation behind them.

Major new features 🚀

Bleeding edge 🔪

  • Sealed array shapes are truly sealed
  • Array shape like array{a: int, b: string} does not allow for extra keys and does not accept general arrays

If you want to see the shape of things to come and adopt bleeding edge features early, you can include this config file in your project's phpstan.neon:

includes:

    - vendor/phpstan/phpstan/conf/bleedingEdge.neon

Of course, there are no backwards compatibility guarantees when you include this file. The behaviour and reported errors can change in minor versions with this file included. Learn more

Improvements 🔧

  • Allow custom rules to emit collector data for CollectedDataNode with CollectedDataEmitter (#5261)
  • Reduced false positives about constant conditions in traits (#5309), [#13023], [#7599], [#13474], [#13687], [#12798], [#11949], [#12267], [#9515], [#4570], [#4121], [#8060], [#10353]

Bugfixes 🐛

  • Narrow division to int when modulo is known to be zero (#5757), [#9724], thanks @VincentLanglet and @staabm!
  • Do not normalize union types in tryRemove to preserve finite type combinations (#5744), [#10128], [#11453], thanks @VincentLanglet and @staabm!
  • Prevent infinite recursion in AttributeReflectionFactory when an attribute references itself on its constructor (#5773), [#14707]

Internals 🔍

  • Refactor TypeSpecifier (#5772), thanks @VincentLanglet!
  • Simplify InitializerExprTypeResolver api-surface (#5767), thanks @staabm!
  • Cleanup ArrayType::tryRemove() (#5766), thanks @staabm!
Source: README.md, updated 2026-05-28