Skip to content

Commit

Permalink
PHPStan: Ignore incompatible PHPUnit argument type on PHP ≤ 7.4
Browse files Browse the repository at this point in the history
In psr/simple-cache < 2.0.0, which is installed on PHP 7.4 or lower,
the `Psr\SimpleCache\InvalidArgumentException` interface does not extend `Throwable`.
But the current versions of PHPUnit require subtypes of `Throwable` to be given to `expectException()` method.
As a result, PHPStan will complain when we try to expect the non-`Throwable`-inheriting interface:

    Parameter simplepie#1 $exception of method PHPUnit\Framework\TestCase::expectException() expects class-string<Throwable>, string given.
  • Loading branch information
jtojnar committed Aug 6, 2023
1 parent bc96e0f commit ab9e3e5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ parameters:
# Only occurs on PHP ≥ 8.0
reportUnmatched: false

-
message: '(^Parameter #1 \$exception of method PHPUnit\\Framework\\TestCase::expectException\(\) expects class-string<Throwable>, string given\.$)'

count: 3
path: tests/Unit/Cache/Psr16Test.php
# Only occurs on PHP ≤ 7.4
reportUnmatched: false

# PHPStan stubs bug https://github.com/phpstan/phpstan/issues/8629
-
message: '(^Access to an undefined property XMLReader::\$\w+\.$)'
Expand Down

0 comments on commit ab9e3e5

Please sign in to comment.