Skip to content

Commit

Permalink
:octocat: run phpstan on the benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Jul 21, 2024
1 parent 1617ed0 commit e6b1ff0
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
1 change: 0 additions & 1 deletion benchmark/QRDataBenchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function initBitBuffer():void{
#[Subject]
#[BeforeMethods(['assignParams', 'generateTestData', 'initOptions'])]
public function invocation():void{
/** @phan-suppress-next-line PhanNoopNew */
new QRData($this->options, [new $this->modeFQCN($this->testData)]);
}

Expand Down
2 changes: 0 additions & 2 deletions benchmark/generate-html.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @author smiley <smiley@chillerlan.net>
* @copyright 2024 smiley
* @license MIT
*
* @phan-file-suppress PhanTypeArraySuspiciousNullable
*/
declare(strict_types=1);

Expand Down
12 changes: 8 additions & 4 deletions benchmark/generate-markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @author smiley <smiley@chillerlan.net>
* @copyright 2024 smiley
* @license MIT
*
* @phan-file-suppress PhanTypeArraySuspiciousNullable
*/
declare(strict_types=1);

Expand All @@ -30,10 +28,16 @@
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
Expand Down
45 changes: 45 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ parameters:
level: 8
tmpDir: .build/phpstan-cache
paths:
- benchmark
- examples
- src
- tests
Expand Down

0 comments on commit e6b1ff0

Please sign in to comment.