From 0173075717e29eb774b358f4a63c5a7ec179860d Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Sun, 3 Oct 2021 22:35:13 -0700 Subject: [PATCH] Enabled exception analysis and fixed many static analysis errors --- phpstan-baseline.neon | 55 +++++++++++++++++++++++++++++++++++++++++++ phpstan-ignores.neon | 4 ++++ phpstan.neon.dist | 22 +++++++++++------ 3 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 phpstan-ignores.neon diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6a52251..2e4a244 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -20,6 +20,61 @@ parameters: count: 1 path: app/config/container.php + - + message: "#^Method App\\\\Controllers\\\\DirectoryController\\:\\:__invoke\\(\\) throws checked exception Twig\\\\Error\\\\LoaderError but it's missing from the PHPDoc @throws tag\\.$#" + count: 2 + path: app/src/Controllers/DirectoryController.php + + - + message: "#^Method App\\\\Controllers\\\\DirectoryController\\:\\:__invoke\\(\\) throws checked exception Twig\\\\Error\\\\RuntimeError but it's missing from the PHPDoc @throws tag\\.$#" + count: 2 + path: app/src/Controllers/DirectoryController.php + + - + message: "#^Method App\\\\Controllers\\\\DirectoryController\\:\\:__invoke\\(\\) throws checked exception Twig\\\\Error\\\\SyntaxError but it's missing from the PHPDoc @throws tag\\.$#" + count: 2 + path: app/src/Controllers/DirectoryController.php + + - + message: "#^Method App\\\\Controllers\\\\SearchController\\:\\:__invoke\\(\\) throws checked exception Twig\\\\Error\\\\LoaderError but it's missing from the PHPDoc @throws tag\\.$#" + count: 2 + path: app/src/Controllers/SearchController.php + + - + message: "#^Method App\\\\Controllers\\\\SearchController\\:\\:__invoke\\(\\) throws checked exception Twig\\\\Error\\\\RuntimeError but it's missing from the PHPDoc @throws tag\\.$#" + count: 2 + path: app/src/Controllers/SearchController.php + + - + message: "#^Method App\\\\Controllers\\\\SearchController\\:\\:__invoke\\(\\) throws checked exception Twig\\\\Error\\\\SyntaxError but it's missing from the PHPDoc @throws tag\\.$#" + count: 2 + path: app/src/Controllers/SearchController.php + + - + message: "#^Method App\\\\Exceptions\\\\ErrorHandler\\:\\:__invoke\\(\\) throws checked exception Twig\\\\Error\\\\LoaderError but it's missing from the PHPDoc @throws tag\\.$#" + count: 1 + path: app/src/Exceptions/ErrorHandler.php + + - + message: "#^Method App\\\\Exceptions\\\\ErrorHandler\\:\\:__invoke\\(\\) throws checked exception Twig\\\\Error\\\\RuntimeError but it's missing from the PHPDoc @throws tag\\.$#" + count: 1 + path: app/src/Exceptions/ErrorHandler.php + + - + message: "#^Method App\\\\Exceptions\\\\ErrorHandler\\:\\:__invoke\\(\\) throws checked exception Twig\\\\Error\\\\SyntaxError but it's missing from the PHPDoc @throws tag\\.$#" + count: 1 + path: app/src/Exceptions/ErrorHandler.php + + - + message: "#^Method App\\\\Factories\\\\TwigFactory\\:\\:__invoke\\(\\) throws checked exception ReflectionException but it's missing from the PHPDoc @throws tag\\.$#" + count: 1 + path: app/src/Factories/TwigFactory.php + + - + message: "#^Method App\\\\Middlewares\\\\PruneCacheMiddleware\\:\\:winsLottery\\(\\) throws checked exception Exception but it's missing from the PHPDoc @throws tag\\.$#" + count: 1 + path: app/src/Middlewares/PruneCacheMiddleware.php + - message: "#^Parameter \\#1 \\$separator of function explode expects non\\-empty\\-string, string given\\.$#" count: 1 diff --git a/phpstan-ignores.neon b/phpstan-ignores.neon new file mode 100644 index 0000000..f214110 --- /dev/null +++ b/phpstan-ignores.neon @@ -0,0 +1,4 @@ +parameters: + ignoreErrors: + - message: "/^Method .+ throws checked exception .+ but it's missing from the PHPDoc @throws tag.$/" + path: tests/* diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 02b651d..3355b10 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -20,14 +20,22 @@ parameters: reportUnmatchedIgnoredErrors: false - # exceptions: - # check: - # missingCheckedExceptionInThrows: true - # tooWideThrowType: true + exceptions: + check: + missingCheckedExceptionInThrows: true + tooWideThrowType: true - # uncheckedExceptionClasses: - # - 'PHPUnit\Framework\Exception' - # - 'SebastianBergmann\RecursionContext\InvalidArgumentException' + uncheckedExceptionClasses: + - 'DI\DependencyException' + - 'InvalidArgumentException' + - 'Invoker\Exception\NotCallableException' + - 'LogicException' + - 'RuntimeException' + - 'Psr\Cache\InvalidArgumentException' + - 'SebastianBergmann\RecursionContext\InvalidArgumentException' + - 'Symfony\Component\Cache\Exception\CacheException' + - 'PHPUnit\Framework\Exception' includes: - phpstan-baseline.neon + - phpstan-ignores.neon