Enabled exception analysis and fixed many static analysis errors

This commit is contained in:
Chris Kankiewicz
2021-10-03 22:35:13 -07:00
parent 2a30bd1ee4
commit 0173075717
3 changed files with 74 additions and 7 deletions

View File

@@ -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

4
phpstan-ignores.neon Normal file
View File

@@ -0,0 +1,4 @@
parameters:
ignoreErrors:
- message: "/^Method .+ throws checked exception .+ but it's missing from the PHPDoc @throws tag.$/"
path: tests/*

View File

@@ -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