Skip to content

Releases: thecodingmachine/phpstan-strict-rules

v0.10.5

13 Oct 13:54
81bb234
Compare
Choose a tag to compare

Improvements:

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

v0.10.4

12 Oct 14:53
b61c37d
Compare
Choose a tag to compare

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

Default is compulsory in switch statements

06 Jul 12:43
4171d44
Compare
Choose a tag to compare

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 aka the "no-superglobals release"

06 Jul 09:42
1c12746
Compare
Choose a tag to compare

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

Switching to PHPStan docblock parser

04 Jul 13:43
e0892ef
Compare
Choose a tag to compare

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

25 Jun 15:52
985ca90
Compare
Choose a tag to compare

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

Bugfix release

23 Apr 19:48
7bfd9a9
Compare
Choose a tag to compare
  • 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

27 Mar 14:01
fd5efdf
Compare
Choose a tag to compare
  • #20: iterable PHP types can now be casted to SomeObject[]

v0.9

29 Nov 16:49
d5ed0b0
Compare
Choose a tag to compare

This release brings compatibility with the new PHPStan 0.9 release.

Bugfix release

09 Nov 16:10
f2b8d44
Compare
Choose a tag to compare

Fixes the reading of @param annotations with no typehint

eg.

See #17