NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #3877 most downloaded on Packagist
A set of additional rules for PHPStan based on best practices followed at TheCodingMachine
Latest stable
v2.0.0
Last release 4 months ago
27 Jun 2026
Ships unpredictably
gaps range from 8 days to 4.6 years
Nearly every release is documented
notes for 28 of 31 stable releases
Nothing withdrawn
no release was ever pulled
9 years old
31 releases · first in 2017
Drag across the ruler to compare, or tap a release to open it.
Update for php 8.2 and phpstan 2.x by @mugagambi in https://github.com/thecodingmachine/phpstan-strict-rules/pull/69
Full Changelog: https://github.com/thecodingmachine/phpstan-strict-rules/compare/v1.0.0...v2.0.0
This release targets PHPStan v1.0.0
This release targets PHPStan v1.0.0
Fixing compatibility with PHP8 when no variable is set in the catch block #57 #59 (@dongm2ez)
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Bugfix:
- #56 Allowing install with PHP 8 (@TomasVotruba)
This release brings compatibility with PHPStan 0.12.
This release brings compatibility with PHPStan 0.12.
Because PHPStan 0.12 new level 6 does all the type checking we used to do, the type checking related rules of phpstan-strict-rules have been removed from this package.
See https://github.com/thecodingmachine/phpstan-strict-rules/commit/e3d746a61d38993ca2bc2e2fcda7012150de120c
See https://github.com/thecodingmachine/phpstan-strict-rules/commit/e3d746a61d38993ca2bc2e2fcda7012150de120c
- #48 Added support for phpstan-extension-installer. Credits to @sspat
Tagging v0.11.0 to keep the same numbering scheme as PHPStan (current version is 0.11) v0.11.0 is actually the SAME release as v0.10.8.
Tagging v0.11.0 to keep the same numbering scheme as PHPStan (current version is 0.11) v0.11.0 is actually the SAME release as v0.10.8.
- #44 Adding a special annotation that allows to ignore empty catch statement errors - #46 Adding PHPStan 0.11 compatibility
Bugfix: - #39 void return types declared in PHPDoc but not natively are now detected.
Bugfix:
Moire improvements: - #38 More bitly links to more detailed explanations of errors reported
Moire improvements:
Adding bitly links to more detailed explanations of errors reported. See #36
Improvements:
When catching Exception, Throwable or RuntimeException, we should ensure that the exception is always rethrown (or wrapped into another exception that
New rule:
When catching Exception, Throwable or RuntimeException, we should ensure that the exception is always rethrown (or wrapped into another exception that is thrown).
This release adds a new rule making "default" statement compulsory in "switch" statements. See #29
This release adds a new rule making "default" statement compulsory in "switch" statements. See #29
Rationale:
Just imagine you have a function that does some processing on an article, based on its status. Its status can be "active", "pending" or "inactive"
What you should NOT do:
function doStuff($status) {
switch ($status) {
case "active":
// Do some stuff
break;
case "pending":
// Do some stuff
break;
case "inactive":
// Do some stuff
break;
}
}
But in the future, what if a new status is added, like "archived"? How long will it take before you notice?
So your code should look like this:
function doStuff($status) {
switch ($status) {
case "active":
// Do some stuff
break;
case "pending":
// Do some stuff
break;
case "inactive":
// Do some stuff
break;
default:
// This is good! In case an unexpected status is sent, you will notice
throw InvalidStatusException(sprintf("Unknown Status '%s'", $status));
}
}
By adding a default statement that throws an exception, you are sure to notice if something goes wrong in the future.
This release adds a new rule that forbids the usage of HTTP related superglobals.
This release adds a new rule that forbids the usage of HTTP related superglobals.
index.php to initialize PSR-7 request object)The rationale is that your framework should have a Request object to deal with it (PSR-7 FTW!)
This release uses PHPStan native docblock parser to analyse docblocks.
This release uses PHPStan native docblock parser to analyse docblocks.
PHPStan reflection is now powerful enough that there is no need to add better-reflection on top of it.
As a result, there is an incredible x10 speedup of PHPStan.
\o/
See #27 and #24
First version compatible with PHPStan 0.10 (see #25) Courtesy of @Slamdunk.
First version compatible with PHPStan 0.10 (see #25) Courtesy of @Slamdunk.
Fixes behaviour when type-hinting Iterators
- #20: iterable PHP types can now be casted to SomeObject[]
Fixes the reading of @param annotations with no typehint
Fixes the reading of @param annotations with no typehint
eg.
See #17
Nothing published for this version
Adding differenciation between array docblock typehint (bad) and mixed[] docblock typehint (good) See #15
Adding differenciation between array docblock typehint (bad) and mixed[] docblock typehint (good) See #15
So far, thecodingmachine/phpstan-strict-rules used the latest master version of roave/better-reflection. Now the v2 was tagged, this release updates t
So far, thecodingmachine/phpstan-strict-rules used the latest master version of roave/better-reflection. Now the v2 was tagged, this release updates the composer.json dependency to target v2.
Fixing a BC break in roave/better-reflection See #13
Fixing a BC break in roave/better-reflection See #13
Nothing published for this version
Keeping in sync with Betterreflection master branch that changed a few namespaces.
Keeping in sync with Betterreflection master branch that changed a few namespaces.
Fixes detection of extended classes when doing typehint analyses. See #9
Fixes detection of extended classes when doing typehint analyses. See #9
Also, simplfies the configuration using "includes". See #8
See #5
Also, simplfies the configuration using "includes". See #8
This is needed to support PHP 7.1 type-hints.
This is needed to support PHP 7.1 type-hints.
Includes checks on exceptions and type-hints (but limited to PHP 7.0 type-hints)
Includes checks on exceptions and type-hints (but limited to PHP 7.0 type-hints)
Nothing published for this version
One column per quarter.