From ad95782916d6fab96e386a4760dd70084f946da5 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Mon, 29 Oct 2018 09:48:17 +0100 Subject: [PATCH 1/2] Fix error raised by PHPStan --- src/ErrorTypesParser.php | 4 ++++ test/ErrorTypesParserTest.php | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/ErrorTypesParser.php b/src/ErrorTypesParser.php index a5c21950..c31d2afc 100644 --- a/src/ErrorTypesParser.php +++ b/src/ErrorTypesParser.php @@ -55,6 +55,10 @@ private function convertErrorConstants(string $expression): string return $errorConstant[0]; }, $expression); + if (null === $output) { + throw new \InvalidArgumentException('Unable to parse error types string: ' . $expression); + } + return $output; } diff --git a/test/ErrorTypesParserTest.php b/test/ErrorTypesParserTest.php index bd4e1ae2..ec13306d 100644 --- a/test/ErrorTypesParserTest.php +++ b/test/ErrorTypesParserTest.php @@ -20,4 +20,12 @@ public function test_error_types_parser_throws_exception_for_unwanted_values() $this->expectException(\InvalidArgumentException::class); $ex->parse(); } + + public function test_error_types_parser_throws_exception_for_unparsable_values() + { + $ex = new ErrorTypesParser('something-wrong'); + + $this->expectException(\InvalidArgumentException::class); + $ex->parse(); + } } From 77b7f5da54ab9d8220586b40bb9e3ac5abfb7036 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Mon, 29 Oct 2018 09:49:59 +0100 Subject: [PATCH 2/2] Parametrize PHPStan build in config file --- composer.json | 2 +- phpstan.neon | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 454fb7a6..310d9209 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ } }, "scripts": { - "phpstan": "vendor/bin/phpstan analyse src test --level 7 -c phpstan.neon", + "phpstan": "vendor/bin/phpstan analyse", "cs-check": "vendor/bin/php-cs-fixer fix --verbose --diff --dry-run", "cs-fix": "vendor/bin/php-cs-fixer fix --verbose --diff" }, diff --git a/phpstan.neon b/phpstan.neon index 6895855a..3d861b27 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,8 @@ parameters: + level: 7 + paths: + - src/ + - test/ ignoreErrors: - '/Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent/' - '/Call to an undefined method Symfony\\Component\\Console\\Event\\ConsoleEvent::getExitCode\(\)\./'