From e6b1ff0adacb3bdb5a04cb4ed1ed66ea39df6125 Mon Sep 17 00:00:00 2001 From: smiley Date: Sun, 21 Jul 2024 22:18:18 +0200 Subject: [PATCH] :octocat: run phpstan on the benchmarks --- benchmark/QRDataBenchmark.php | 1 - benchmark/generate-html.php | 2 -- benchmark/generate-markdown.php | 12 ++++++--- phpstan-baseline.neon | 45 +++++++++++++++++++++++++++++++++ phpstan.dist.neon | 1 + 5 files changed, 54 insertions(+), 7 deletions(-) diff --git a/benchmark/QRDataBenchmark.php b/benchmark/QRDataBenchmark.php index 158158987..83b4d6251 100644 --- a/benchmark/QRDataBenchmark.php +++ b/benchmark/QRDataBenchmark.php @@ -48,7 +48,6 @@ final class QRDataBenchmark extends BenchmarkAbstract{ #[Subject] #[BeforeMethods(['assignParams', 'generateTestData', 'initOptions'])] public function invocation():void{ - /** @phan-suppress-next-line PhanNoopNew */ new QRData($this->options, [new $this->modeFQCN($this->testData)]); } diff --git a/benchmark/generate-html.php b/benchmark/generate-html.php index a8cdb1741..5477d6dce 100644 --- a/benchmark/generate-html.php +++ b/benchmark/generate-html.php @@ -6,8 +6,6 @@ * @author smiley * @copyright 2024 smiley * @license MIT - * - * @phan-file-suppress PhanTypeArraySuspiciousNullable */ declare(strict_types=1); diff --git a/benchmark/generate-markdown.php b/benchmark/generate-markdown.php index 843e7b494..d7a4d8fef 100644 --- a/benchmark/generate-markdown.php +++ b/benchmark/generate-markdown.php @@ -6,8 +6,6 @@ * @author smiley * @copyright 2024 smiley * @license MIT - * - * @phan-file-suppress PhanTypeArraySuspiciousNullable */ declare(strict_types=1); @@ -30,10 +28,16 @@ use function strtolower; require_once __DIR__.'/parse-common.php'; if(!file_exists(FILE.'.json')){ - throw new RuntimeException('invalid benchmark report'); + throw new RuntimeException('invalid benchmark report [file_exists()]'); } -$json = json_decode(file_get_contents(FILE.'.json'), true); +$data = file_get_contents(FILE.'.json'); + +if($data === false){ + throw new RuntimeException('invalid benchmark report [file_get_contents()]'); +} + +$json = json_decode($data, true); $markdown = []; // General information/overview diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 7c8940ef5..ea17038f6 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,5 +1,50 @@ parameters: ignoreErrors: + - + message: "#^Property chillerlan\\\\QRCodeBenchmark\\\\DecoderBenchmark\\:\\:\\$imageBlob \\(string\\) does not accept GdImage\\|string\\.$#" + count: 1 + path: benchmark/DecoderBenchmark.php + + - + message: "#^Parameter \\#1 \\$segment of method chillerlan\\\\QRCode\\\\QRCode\\:\\:addSegment\\(\\) expects chillerlan\\\\QRCode\\\\Data\\\\QRDataModeInterface, object given\\.$#" + count: 1 + path: benchmark/QRCodeBenchmark.php + + - + message: "#^Parameter \\#2 \\$dataSegments of class chillerlan\\\\QRCode\\\\Data\\\\QRData constructor expects array\\, array\\ given\\.$#" + count: 2 + path: benchmark/QRDataBenchmark.php + + - + message: "#^Parameter \\#1 \\$string of function strtolower expects string, int\\|string given\\.$#" + count: 1 + path: benchmark/generate-markdown.php + + - + message: "#^Offset 'name' does not exist on array\\\\.$#" + count: 1 + path: benchmark/parse-common.php + + - + message: "#^Offset 'results' does not exist on array\\\\.$#" + count: 1 + path: benchmark/parse-common.php + + - + message: "#^Offset 0 does not exist on array\\{\\}\\.$#" + count: 1 + path: benchmark/parse-common.php + + - + message: "#^Function chillerlan\\\\QRCodeBenchmark\\\\parseLine\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: benchmark/parse-result.php + + - + message: "#^Parameter \\#1 \\$string of function trim expects string, string\\|false given\\.$#" + count: 1 + path: benchmark/parse-result.php + - message: "#^Property chillerlan\\\\QRCode\\\\QROptions\\:\\:\\$eccLevel \\(int\\) does not accept string\\.$#" count: 1 diff --git a/phpstan.dist.neon b/phpstan.dist.neon index ce6281b4c..445b277f5 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -4,6 +4,7 @@ parameters: level: 8 tmpDir: .build/phpstan-cache paths: + - benchmark - examples - src - tests