thecodingmachine/phpstan-strict-rules
Extra-strict PHPStan ruleset that flags risky or inconsistent PHP patterns beyond the default checks. Helps enforce cleaner, safer code by catching edge cases and enforcing best practices, with easy opt-in configuration for existing PHPStan setups.
This release targets PHPStan v1.0.0
Bugfix:
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.
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.
Bugfix:
Moire improvements:
Improvements:
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
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.
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.
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.
This release brings compatibility with the new PHPStan 0.9 release.
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 the composer.json dependency to target v2.
Fixing a BC break in roave/better-reflection See #13
Keeping in sync with Betterreflection master branch that changed a few namespaces.
Fixes detection of extended classes when doing typehint analyses. See #9
See #5
Also, simplfies the configuration using "includes". See #8
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)
How can I help you explore Laravel packages today?