Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpstan Strict Rules Laravel Package

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.

View on GitHub
Deep Wiki
Context7
v1.0.0

This release targets PHPStan v1.0.0

v0.12.2

Bugfix:

  • Fixing compatibility with PHP8 when no variable is set in the catch block #57 #59 (@dongm2ez)
v0.12.1
v0.12.0

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.

v0.11.1
  • #48 Added support for phpstan-extension-installer. Credits to @sspat
v0.11.0

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.

v0.10.8
  • #44 Adding a special annotation that allows to ignore empty catch statement errors
  • #46 Adding PHPStan 0.11 compatibility
v0.10.7

Bugfix:

  • #39 void return types declared in PHPDoc but not natively are now detected.
v0.10.6

Moire improvements:

  • #38 More bitly links to more detailed explanations of errors reported
v0.10.5

Improvements:

  • Adding bitly links to more detailed explanations of errors reported. See #36
v0.10.4

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).

v0.10.3

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.

v0.10.2

This release adds a new rule that forbids the usage of HTTP related superglobals.

  • The use of $_GET, $_POST, $_FILES, $_COOKIE, $_SESSION, $_REQUEST is forbidden. You should instead use your framework's request/session object.
  • Superglobal usage is still tolerated at the root scope (because it is typically used once in 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!)

v0.10.1

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

v0.10.0

First version compatible with PHPStan 0.10 (see #25) Courtesy of @Slamdunk.

v0.9.2
  • Fixes behaviour when type-hinting Iterators (#21)
  • Fixes errors when non-parseable docblocks are encountered (#22)
  • Fixes "object" type-hinting compatibility with PHP 7.1 (#23)
v0.9.1
  • #20: iterable PHP types can now be casted to SomeObject[]
v0.9.0

This release brings compatibility with the new PHPStan 0.9 release.

v0.8.5

Fixes the reading of @param annotations with no typehint

eg.

See #17

v0.8.4
v0.8.3

Adding differenciation between array docblock typehint (bad) and mixed[] docblock typehint (good) See #15

v0.8.2

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.

v0.8.1

Fixing a BC break in roave/better-reflection See #13

v0.8.0
v0.7.4

Keeping in sync with Betterreflection master branch that changed a few namespaces.

v0.7.3

Fixes detection of extended classes when doing typehint analyses. See #9

v0.7.2

See #5

Also, simplfies the configuration using "includes". See #8

v0.7.1

This is needed to support PHP 7.1 type-hints.

0.7.0

Includes checks on exceptions and type-hints (but limited to PHP 7.0 type-hints)

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4