Преглед на файлове

:octocat: run phpstan on the benchmarks

smiley преди 1 година
родител
ревизия
e6b1ff0ada
променени са 5 файла, в които са добавени 54 реда и са изтрити 7 реда
  1. 0 1
      benchmark/QRDataBenchmark.php
  2. 0 2
      benchmark/generate-html.php
  3. 8 4
      benchmark/generate-markdown.php
  4. 45 0
      phpstan-baseline.neon
  5. 1 0
      phpstan.dist.neon

+ 0 - 1
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)]);
 	}
 

+ 0 - 2
benchmark/generate-html.php

@@ -6,8 +6,6 @@
  * @author       smiley <smiley@chillerlan.net>
  * @copyright    2024 smiley
  * @license      MIT
- *
- * @phan-file-suppress PhanTypeArraySuspiciousNullable
  */
 declare(strict_types=1);
 

+ 8 - 4
benchmark/generate-markdown.php

@@ -6,8 +6,6 @@
  * @author       smiley <smiley@chillerlan.net>
  * @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()]');
+}
+
+$data = file_get_contents(FILE.'.json');
+
+if($data === false){
+	throw new RuntimeException('invalid benchmark report [file_get_contents()]');
 }
 
-$json     = json_decode(file_get_contents(FILE.'.json'), true);
+$json     = json_decode($data, true);
 $markdown = [];
 
 // General information/overview

+ 45 - 0
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\\<chillerlan\\\\QRCode\\\\Data\\\\QRDataModeInterface\\>, array\\<int, object\\> 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\\<int, mixed\\>\\.$#"
+			count: 1
+			path: benchmark/parse-common.php
+
+		-
+			message: "#^Offset 'results' does not exist on array\\<int, mixed\\>\\.$#"
+			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

+ 1 - 0
phpstan.dist.neon

@@ -4,6 +4,7 @@ parameters:
 	level: 8
 	tmpDir: .build/phpstan-cache
 	paths:
+		- benchmark
 		- examples
 		- src
 		- tests