Skip to content

Commit f37ea54

Browse files
authored
Bump PHPStan to ^2 (#88)
1 parent 609125d commit f37ea54

File tree

5 files changed

+91
-7
lines changed

5 files changed

+91
-7
lines changed

.github/workflows/code-quality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
continue-on-error: true
3636
run: |
3737
composer config --no-plugins allow-plugins.phpstan/extension-installer true
38-
composer require --ansi --dev "vimeo/psalm:^5.15" "phpstan/phpstan:>=1.10" "phpstan/extension-installer:>=1.4" "phpstan/phpstan-phpunit:>=1.4" "squizlabs/php_codesniffer:>=3.7" "phpunit/phpunit:>=10"
38+
composer require --ansi --dev "vimeo/psalm:^5.15" "phpstan/phpstan:>=2" "phpstan/extension-installer:>=1.4" "phpstan/phpstan-phpunit:>=1.4" "squizlabs/php_codesniffer:>=3.7" "phpunit/phpunit:>=10"
3939
4040
- name: "Run static analysis with phpstan/phpstan"
4141
run: "vendor/bin/phpstan"

phpstan-baseline.neon

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Call to function is_string\(\) with class\-string\<FileEye\\MimeMap\\Map\\MimeMapInterface\> will always evaluate to true\.$#'
5+
identifier: function.alreadyNarrowedType
6+
count: 1
7+
path: src/Command/UpdateCommand.php
8+
9+
-
10+
message: '#^Cannot access offset 0 on mixed\.$#'
11+
identifier: offsetAccess.nonOffsetAccessible
12+
count: 1
13+
path: src/Command/UpdateCommand.php
14+
15+
-
16+
message: '#^Cannot access offset 1 on mixed\.$#'
17+
identifier: offsetAccess.nonOffsetAccessible
18+
count: 1
19+
path: src/Command/UpdateCommand.php
20+
21+
-
22+
message: '#^Cannot access offset 2 on mixed\.$#'
23+
identifier: offsetAccess.nonOffsetAccessible
24+
count: 1
25+
path: src/Command/UpdateCommand.php
26+
27+
-
28+
message: '#^Parameter \#2 \$args of function call_user_func_array expects array\<int\|string, mixed\>, mixed given\.$#'
29+
identifier: argument.type
30+
count: 1
31+
path: src/Command/UpdateCommand.php
32+
33+
-
34+
message: '#^Part \$command\[0\] \(mixed\) of encapsed string cannot be cast to string\.$#'
35+
identifier: encapsedStringPart.nonString
36+
count: 1
37+
path: src/Command/UpdateCommand.php
38+
39+
-
40+
message: '#^Part \$error \(mixed\) of encapsed string cannot be cast to string\.$#'
41+
identifier: encapsedStringPart.nonString
42+
count: 1
43+
path: src/Command/UpdateCommand.php
44+
45+
-
46+
message: '#^Method FileEye\\MimeMap\\Map\\BaseMap\:\:getMapSubEntry\(\) should return list\<string\> but returns array\<int, string\>\.$#'
47+
identifier: return.type
48+
count: 1
49+
path: src/Map/BaseMap.php
50+
51+
-
52+
message: '#^Method FileEye\\MimeMap\\Map\\BaseMap\:\:listEntries\(\) should return list\<int\|string\> but returns array\<int\<0, max\>, int\|string\>\.$#'
53+
identifier: return.type
54+
count: 1
55+
path: src/Map/BaseMap.php
56+
57+
-
58+
message: '#^Binary operation "\." between ''\: '' and mixed results in an error\.$#'
59+
identifier: binaryOp.invalid
60+
count: 1
61+
path: src/MapUpdater.php
62+
63+
-
64+
message: '#^Parameter \#1 \$format of method FileEye\\MimeMap\\Type\:\:toString\(\) expects int, mixed given\.$#'
65+
identifier: argument.type
66+
count: 7
67+
path: src/Type.php
68+
69+
-
70+
message: '#^Parameter \#1 \$format of method FileEye\\MimeMap\\TypeInterface\:\:toString\(\) expects int, mixed given\.$#'
71+
identifier: argument.type
72+
count: 3
73+
path: src/Type.php
74+
75+
-
76+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''FileEye\\\\MimeMap\\\\TypeParameter'' and FileEye\\MimeMap\\TypeParameter will always evaluate to true\.$#'
77+
identifier: method.alreadyNarrowedType
78+
count: 1
79+
path: tests/src/TypeTest.php

phpstan.neon.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
14
parameters:
25
level: max
6+
37
paths:
48
- src
59
- tests

src/Command/UpdateCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,26 @@ protected function configure(): void
3434
null,
3535
InputOption::VALUE_REQUIRED,
3636
'File name of the script containing the sequence of commands to execute to build the default map.',
37-
MapUpdater::getDefaultMapBuildFile()
37+
MapUpdater::getDefaultMapBuildFile(),
3838
)
3939
->addOption(
4040
'class',
4141
null,
4242
InputOption::VALUE_REQUIRED,
4343
'The fully qualified class name of the PHP class storing the map.',
44-
MapHandler::DEFAULT_MAP_CLASS
44+
MapHandler::DEFAULT_MAP_CLASS,
4545
)
4646
->addOption(
4747
'diff',
4848
null,
4949
InputOption::VALUE_NONE,
50-
'Report updates.'
50+
'Report updates.',
5151
)
5252
->addOption(
5353
'fail-on-diff',
5454
null,
5555
InputOption::VALUE_NONE,
56-
'Exit with an error when a difference is found. Map will not be updated.'
56+
'Exit with an error when a difference is found. Map will not be updated.',
5757
)
5858
;
5959
}

src/MapUpdater.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ public function loadMapFromFreedesktopFile(string $source_file): array
148148
}
149149
if (isset($node->acronym)) {
150150
$acronym = (string) $node->acronym;
151-
if (isset($node->{'expanded-acronym'})) {
152-
$acronym .= ': ' . (string) $node->{'expanded-acronym'};
151+
$expandedAcronym = $node->{'expanded-acronym'} ?? null;
152+
if (isset($expandedAcronym)) {
153+
$acronym .= ': ' . $expandedAcronym;
153154
}
154155
$this->map->addTypeDescription($type, $acronym);
155156
}

0 commit comments

Comments
 (0)