diff options
author | n-peugnet <n.peugnet@free.fr> | 2020-04-20 20:24:44 +0200 |
---|---|---|
committer | Vincent Peugnet <33429034+vincent-peugnet@users.noreply.github.com> | 2020-04-21 14:56:53 +0200 |
commit | 6a002dde678907abc355e3afecc3b67da866f8cd (patch) | |
tree | 5ec0d15161cffa967351166281aa8f34b4f2742e | |
parent | 618b22ab217b773d18abfce8bfe4dd6960738371 (diff) | |
download | wcms-6a002dde678907abc355e3afecc3b67da866f8cd.tar.gz wcms-6a002dde678907abc355e3afecc3b67da866f8cd.zip |
tests: add exception phpstan extensions
-rw-r--r-- | app/class/Routes.php | 3 | ||||
-rw-r--r-- | composer.json | 1 | ||||
-rw-r--r-- | composer.lock | 56 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | phpstan.neon | 11 |
5 files changed, 71 insertions, 2 deletions
diff --git a/app/class/Routes.php b/app/class/Routes.php index c58de95..2a1e088 100644 --- a/app/class/Routes.php +++ b/app/class/Routes.php @@ -3,11 +3,14 @@ namespace Wcms; use AltoRouter; +use Exception; class Routes { /** * Cherche une correspondance entre l'URL et les routes, et appelle la méthode appropriée + * + * @throws Exception if addRoutes fails (maybe it should be catched). */ public function match() { diff --git a/composer.json b/composer.json index 8640d17..ab94f5d 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "michelf/php-markdown": "^1.8" }, "require-dev": { + "pepakriz/phpstan-exception-rules": "^0.10.1", "phpstan/phpstan": "^0.12.19", "phpunit/phpunit": "^8.5", "sentry/sdk": "^2.0", diff --git a/composer.lock b/composer.lock index d7b1737..cc5d693 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "b26e62f8b85c611f3db528f8690e4dfe", + "content-hash": "78878874876578b163daba4b9d866b23", "packages": [ { "name": "altorouter/altorouter", @@ -698,6 +698,60 @@ "time": "2018-07-02T15:55:56+00:00" }, { + "name": "pepakriz/phpstan-exception-rules", + "version": "v0.10.1", + "source": { + "type": "git", + "url": "https://github.com/pepakriz/phpstan-exception-rules.git", + "reference": "7073711906e22509cbfacbca0a914e0f8ff2e6c8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pepakriz/phpstan-exception-rules/zipball/7073711906e22509cbfacbca0a914e0f8ff2e6c8", + "reference": "7073711906e22509cbfacbca0a914e0f8ff2e6c8", + "shasum": "" + }, + "require": { + "php": "^7.1", + "phpstan/phpstan": "^0.12.0" + }, + "require-dev": { + "jakub-onderka/php-console-highlighter": "0.4.0", + "jakub-onderka/php-parallel-lint": "1.0.0", + "nette/utils": "^3.0", + "php-coveralls/php-coveralls": "^2.1", + "phpstan/phpstan": "^0.12.0", + "phpstan/phpstan-nette": "^0.12.0", + "phpstan/phpstan-phpunit": "^0.12.0", + "phpstan/phpstan-strict-rules": "^0.12.0", + "phpunit/phpunit": "^7.5.6", + "slevomat/coding-standard": "^5.0.4", + "squizlabs/php_codesniffer": "~3.5.2" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "0.10-dev" + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "Pepakriz\\PHPStanExceptionRules\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Exception rules for PHPStan", + "time": "2019-12-09T06:14:56+00:00" + }, + { "name": "phar-io/manifest", "version": "1.0.3", "source": { @@ -26,7 +26,7 @@ if (isreportingerrors()) { try { $matchoper = new Wcms\Routes(); $matchoper->match(); -} catch (Exception $e) { +} catch (Throwable $e) { if (isreportingerrors()) { Sentry\captureException($e); } diff --git a/phpstan.neon b/phpstan.neon index 8c4765c..6087678 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,3 +1,6 @@ +includes: + - vendor/pepakriz/phpstan-exception-rules/extension.neon + parameters: level: 5 paths: @@ -5,3 +8,11 @@ parameters: - app/fn - index.php - tests + exceptionRules: + # ignore some exceptions and their chlidrens + uncheckedExceptions: + - Error + - LogicException + # ignore all exceptions errors in tests classes + methodWhitelist: + PHPUnit\Framework\TestCase: '#.*#i' |