From f788d6872f40ddda5c949c93bb04b1b8b96d8380 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 26 Mar 2018 17:09:50 +0200 Subject: [PATCH] Added infection to the build matrix --- composer.json | 7 +++++-- infection.json | 18 +++++++++++++++++ .../JsonErrorResponseGenerator.php | 2 +- module/Rest/src/Util/RestUtils.php | 20 +++++++++---------- phpstan.neon | 1 + 5 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 infection.json diff --git a/composer.json b/composer.json index eb6cd2a5..7a755284 100644 --- a/composer.json +++ b/composer.json @@ -47,6 +47,7 @@ }, "require-dev": { "filp/whoops": "^2.0", + "infection/infection": "^0.8.1", "phpstan/phpstan": "0.9", "phpunit/dbunit": "^3.0", "phpunit/phpcov": "^4.0", @@ -87,7 +88,8 @@ "@cs", "@stan", "@test", - "@func-test" + "@func-test", + "@infect" ], "cs": "phpcs", "cs-fix": "phpcbf", @@ -100,7 +102,8 @@ "@func-test", "phpcov merge build --html build/html" ], - "stan": "phpstan analyse module/*/src/ --level=6 -c phpstan.neon" + "stan": "phpstan analyse module/*/src/ --level=6 -c phpstan.neon", + "infect": "infection --threads=4 --min-msi=65 --only-covered --log-verbosity=2" }, "config": { "process-timeout": 0, diff --git a/infection.json b/infection.json new file mode 100644 index 00000000..5f5fb65b --- /dev/null +++ b/infection.json @@ -0,0 +1,18 @@ +{ + "source": { + "directories": [ + "module/*/src" + ], + "excludes": [] + }, + "timeout": 10, + "logs": { + "text": "build/infection/infection-log.txt", + "summary": "build/infection/summary-log.txt", + "debug": "build/infection/debug-log.txt" + }, + "tmpDir": "build/infection/temp", + "phpUnit": { + "configDir": "." + } +} diff --git a/module/Rest/src/ErrorHandler/JsonErrorResponseGenerator.php b/module/Rest/src/ErrorHandler/JsonErrorResponseGenerator.php index 7d0b6013..b62f49cc 100644 --- a/module/Rest/src/ErrorHandler/JsonErrorResponseGenerator.php +++ b/module/Rest/src/ErrorHandler/JsonErrorResponseGenerator.php @@ -20,7 +20,7 @@ class JsonErrorResponseGenerator implements ErrorResponseGeneratorInterface, Sta * @return Response * @throws \InvalidArgumentException */ - public function __invoke($e, Request $request, Response $response) + public function __invoke(?\Throwable $e, Request $request, Response $response) { $status = $response->getStatusCode(); $responsePhrase = $status < 400 ? 'Internal Server Error' : $response->getReasonPhrase(); diff --git a/module/Rest/src/Util/RestUtils.php b/module/Rest/src/Util/RestUtils.php index b9d96891..1d697676 100644 --- a/module/Rest/src/Util/RestUtils.php +++ b/module/Rest/src/Util/RestUtils.php @@ -9,16 +9,16 @@ use Shlinkio\Shlink\Rest\Exception as Rest; class RestUtils { - const INVALID_SHORTCODE_ERROR = 'INVALID_SHORTCODE'; - const INVALID_URL_ERROR = 'INVALID_URL'; - const INVALID_ARGUMENT_ERROR = 'INVALID_ARGUMENT'; - const INVALID_SLUG_ERROR = 'INVALID_SLUG'; - const INVALID_CREDENTIALS_ERROR = 'INVALID_CREDENTIALS'; - const INVALID_AUTH_TOKEN_ERROR = 'INVALID_AUTH_TOKEN'; - const INVALID_AUTHORIZATION_ERROR = 'INVALID_AUTHORIZATION'; - const INVALID_API_KEY_ERROR = 'INVALID_API_KEY'; - const NOT_FOUND_ERROR = 'NOT_FOUND'; - const UNKNOWN_ERROR = 'UNKNOWN_ERROR'; + public const INVALID_SHORTCODE_ERROR = 'INVALID_SHORTCODE'; + public const INVALID_URL_ERROR = 'INVALID_URL'; + public const INVALID_ARGUMENT_ERROR = 'INVALID_ARGUMENT'; + public const INVALID_SLUG_ERROR = 'INVALID_SLUG'; + public const INVALID_CREDENTIALS_ERROR = 'INVALID_CREDENTIALS'; + public const INVALID_AUTH_TOKEN_ERROR = 'INVALID_AUTH_TOKEN'; + public const INVALID_AUTHORIZATION_ERROR = 'INVALID_AUTHORIZATION'; + public const INVALID_API_KEY_ERROR = 'INVALID_API_KEY'; + public const NOT_FOUND_ERROR = 'NOT_FOUND'; + public const UNKNOWN_ERROR = 'UNKNOWN_ERROR'; public static function getRestErrorCodeFromException(\Throwable $e) { diff --git a/phpstan.neon b/phpstan.neon index 77e32e1e..00a81049 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,3 +1,4 @@ parameters: excludes_analyse: - module/Common/src/Template/Extension/TranslatorExtension.php + - module/Rest/src/Util/RestUtils.php