Skip to content

Commit ee31420

Browse files
committed
Merge #45 - Upgrade Psalm and PHPStan
Pull-request: #45 Signed-off-by: Maurício Meneghini Fauth <[email protected]>
2 parents ae2920b + c7694cc commit ee31420

File tree

4 files changed

+129
-38
lines changed

4 files changed

+129
-38
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ jobs:
1111
continue-on-error: ${{ matrix.experimental }}
1212
strategy:
1313
matrix:
14-
php-version: ['8.2', '8.3', '8.4', '8.5']
14+
php-version: ['8.2', '8.3', '8.4']
1515
php-extensions: ['dbase', ':dbase']
1616
os: [ubuntu-latest]
1717
experimental: [false]
1818
composer-options: ['']
1919
include:
20+
- { php-version: '8.5', php-extensions: 'dbase', composer-options: '--ignore-platform-req=php+', experimental: true, os: ubuntu-latest }
21+
- { php-version: '8.5', php-extensions: ':dbase', composer-options: '--ignore-platform-req=php+', experimental: true, os: ubuntu-latest }
2022
- { php-version: '8.6', php-extensions: 'dbase', composer-options: '--ignore-platform-req=php+', experimental: true, os: ubuntu-latest }
2123
- { php-version: '8.6', php-extensions: ':dbase', composer-options: '--ignore-platform-req=php+', experimental: true, os: ubuntu-latest }
2224
steps:

composer.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"@phpunit"
2929
],
3030
"update:baselines": [
31-
"@php phpstan analyse --generate-baseline"
31+
"@php phpstan analyse --generate-baseline",
32+
"@php psalm --set-baseline=psalm-baseline.xml"
3233
]
3334
},
3435
"require": {
@@ -40,13 +41,13 @@
4041
"require-dev": {
4142
"phpmyadmin/coding-standard": "^4.0",
4243
"phpstan/extension-installer": "^1.4",
43-
"phpstan/phpstan": "^1.12",
44-
"phpstan/phpstan-deprecation-rules": "^1.2",
45-
"phpstan/phpstan-phpunit": "^1.4",
46-
"phpstan/phpstan-strict-rules": "^1.6",
44+
"phpstan/phpstan": "^2.1",
45+
"phpstan/phpstan-deprecation-rules": "^2.0",
46+
"phpstan/phpstan-phpunit": "^2.0",
47+
"phpstan/phpstan-strict-rules": "^2.0",
4748
"phpunit/phpunit": "^10.5",
48-
"psalm/plugin-phpunit": "^0.18.4",
49-
"vimeo/psalm": "^5.15"
49+
"psalm/plugin-phpunit": "^0.19.5",
50+
"vimeo/psalm": "^6.13"
5051
},
5152
"autoload": {
5253
"psr-4": {

phpstan-baseline.neon

Lines changed: 92 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,199 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Foreach overwrites \\$i with its key variable\\.$#"
4+
message: '#^Foreach overwrites \$i with its key variable\.$#'
5+
identifier: foreach.keyOverwrite
56
count: 1
67
path: examples/read.php
78

89
-
9-
message: "#^Cannot cast mixed to int\\.$#"
10+
message: '#^Cannot cast mixed to int\.$#'
11+
identifier: cast.int
1012
count: 1
1113
path: src/ShapeFile.php
1214

1315
-
14-
message: "#^Casting to int something that's already int\\.$#"
16+
message: '#^Casting to int something that''s already int\.$#'
17+
identifier: cast.useless
1518
count: 1
1619
path: src/ShapeFile.php
1720

1821
-
19-
message: "#^Only booleans are allowed in a negated boolean, resource\\|false given\\.$#"
22+
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
23+
identifier: notEqual.notAllowed
24+
count: 3
25+
path: src/ShapeFile.php
26+
27+
-
28+
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
29+
identifier: equal.notAllowed
30+
count: 1
31+
path: src/ShapeFile.php
32+
33+
-
34+
message: '#^Only booleans are allowed in a negated boolean, resource\|false given\.$#'
35+
identifier: booleanNot.exprNotBoolean
2036
count: 1
2137
path: src/ShapeFile.php
2238

2339
-
24-
message: "#^Only numeric types are allowed in \\+, int\\|null given on the left side\\.$#"
40+
message: '#^Only numeric types are allowed in \+, int\|null given on the left side\.$#'
41+
identifier: plus.leftNonNumeric
2542
count: 2
2643
path: src/ShapeFile.php
2744

2845
-
29-
message: "#^Only numeric types are allowed in \\+, int\\|null given on the right side\\.$#"
46+
message: '#^Only numeric types are allowed in \+, int\|null given on the right side\.$#'
47+
identifier: plus.rightNonNumeric
3048
count: 1
3149
path: src/ShapeFile.php
3250

3351
-
34-
message: "#^Parameter \\#1 \\$stream of function feof expects resource, resource\\|false given\\.$#"
52+
message: '#^Parameter \#1 \$stream of function feof expects resource, resource\|false given\.$#'
53+
identifier: argument.type
3554
count: 1
3655
path: src/ShapeFile.php
3756

3857
-
39-
message: "#^Parameter \\#1 \\$string of function strtoupper expects string, mixed given\\.$#"
58+
message: '#^Parameter \#1 \$string of function strtoupper expects string, mixed given\.$#'
59+
identifier: argument.type
4060
count: 1
4161
path: src/ShapeFile.php
4262

4363
-
44-
message: "#^Parameter \\#1 \\$string of function substr expects string, string\\|false given\\.$#"
64+
message: '#^Parameter \#1 \$string of function substr expects string, string\|false given\.$#'
65+
identifier: argument.type
4566
count: 6
4667
path: src/ShapeFile.php
4768

4869
-
49-
message: "#^Parameter \\#1 \\$value of static method PhpMyAdmin\\\\ShapeFile\\\\Util\\:\\:packDouble\\(\\) expects float, mixed given\\.$#"
70+
message: '#^Parameter \#1 \$value of static method PhpMyAdmin\\ShapeFile\\Util\:\:packDouble\(\) expects float, mixed given\.$#'
71+
identifier: argument.type
5072
count: 1
5173
path: src/ShapeFile.php
5274

5375
-
54-
message: "#^Parameter \\#2 \\$length of function fread expects int\\<1, max\\>, int\\<0, max\\> given\\.$#"
76+
message: '#^Parameter \#2 \$length of function fread expects int\<1, max\>, int\<0, max\> given\.$#'
77+
identifier: argument.type
5578
count: 1
5679
path: src/ShapeFile.php
5780

5881
-
59-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
82+
message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#'
83+
identifier: foreach.nonIterable
6084
count: 4
6185
path: src/ShapeRecord.php
6286

6387
-
64-
message: "#^Cannot access an offset on mixed\\.$#"
88+
message: '#^Binary operation "\*" between mixed and 2 results in an error\.$#'
89+
identifier: binaryOp.invalid
90+
count: 1
91+
path: src/ShapeRecord.php
92+
93+
-
94+
message: '#^Binary operation "\+" between 1 and mixed results in an error\.$#'
95+
identifier: binaryOp.invalid
96+
count: 2
97+
path: src/ShapeRecord.php
98+
99+
-
100+
message: '#^Cannot access an offset on mixed\.$#'
101+
identifier: offsetAccess.nonOffsetAccessible
65102
count: 4
66103
path: src/ShapeRecord.php
67104

68105
-
69-
message: "#^Cannot access offset 'points' on mixed\\.$#"
70-
count: 15
106+
message: '#^Cannot access offset ''points'' on mixed\.$#'
107+
identifier: offsetAccess.nonOffsetAccessible
108+
count: 11
71109
path: src/ShapeRecord.php
72110

73111
-
74-
message: "#^Cannot access offset int on mixed\\.$#"
75-
count: 12
112+
message: '#^Cannot access offset int on mixed\.$#'
113+
identifier: offsetAccess.nonOffsetAccessible
114+
count: 8
76115
path: src/ShapeRecord.php
77116

78117
-
79-
message: "#^Cannot access offset int\\<\\-1, max\\> on mixed\\.$#"
118+
message: '#^Cannot access offset int\<\-1, max\> on mixed\.$#'
119+
identifier: offsetAccess.nonOffsetAccessible
80120
count: 2
81121
path: src/ShapeRecord.php
82122

83123
-
84-
message: "#^Cannot access offset int\\<0, max\\> on mixed\\.$#"
124+
message: '#^Cannot access offset int\<0, max\> on mixed\.$#'
125+
identifier: offsetAccess.nonOffsetAccessible
85126
count: 12
86127
path: src/ShapeRecord.php
87128

88129
-
89-
message: "#^Cannot access offset int\\<1, max\\> on mixed\\.$#"
130+
message: '#^Cannot access offset int\<1, max\> on mixed\.$#'
131+
identifier: offsetAccess.nonOffsetAccessible
90132
count: 2
91133
path: src/ShapeRecord.php
92134

93135
-
94-
message: "#^Cannot access offset string on mixed\\.$#"
136+
message: '#^Cannot access offset string on mixed\.$#'
137+
identifier: offsetAccess.nonOffsetAccessible
95138
count: 4
96139
path: src/ShapeRecord.php
97140

98141
-
99-
message: "#^Cannot call method hasMeasure\\(\\) on PhpMyAdmin\\\\ShapeFile\\\\ShapeFile\\|null\\.$#"
142+
message: '#^Cannot call method hasMeasure\(\) on PhpMyAdmin\\ShapeFile\\ShapeFile\|null\.$#'
143+
identifier: method.nonObject
100144
count: 2
101145
path: src/ShapeRecord.php
102146

103147
-
104-
message: "#^Cannot call method readSHP\\(\\) on PhpMyAdmin\\\\ShapeFile\\\\ShapeFile\\|null\\.$#"
148+
message: '#^Cannot call method readSHP\(\) on PhpMyAdmin\\ShapeFile\\ShapeFile\|null\.$#'
149+
identifier: method.nonObject
105150
count: 1
106151
path: src/ShapeRecord.php
107152

108153
-
109-
message: "#^Cannot cast mixed to int\\.$#"
154+
message: '#^Cannot cast mixed to int\.$#'
155+
identifier: cast.int
156+
count: 2
157+
path: src/ShapeRecord.php
158+
159+
-
160+
message: '#^Cannot use \-\- on mixed\.$#'
161+
identifier: preDec.type
110162
count: 2
111163
path: src/ShapeRecord.php
112164

113165
-
114-
message: "#^Parameter \\#1 \\$data of method PhpMyAdmin\\\\ShapeFile\\\\ShapeRecord\\:\\:savePoint\\(\\) expects array, mixed given\\.$#"
166+
message: '#^Parameter \#1 \$data of method PhpMyAdmin\\ShapeFile\\ShapeRecord\:\:savePoint\(\) expects array\<mixed\>, mixed given\.$#'
167+
identifier: argument.type
115168
count: 2
116169
path: src/ShapeRecord.php
117170

118171
-
119-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
172+
message: '#^Parameter \#1 \$value of function count expects array\|Countable, mixed given\.$#'
173+
identifier: argument.type
120174
count: 16
121175
path: src/ShapeRecord.php
122176

123177
-
124-
message: "#^Parameter \\#1 \\$value of static method PhpMyAdmin\\\\ShapeFile\\\\Util\\:\\:packDouble\\(\\) expects float, mixed given\\.$#"
178+
message: '#^Parameter \#1 \$value of static method PhpMyAdmin\\ShapeFile\\Util\:\:packDouble\(\) expects float, mixed given\.$#'
179+
identifier: argument.type
125180
count: 11
126181
path: src/ShapeRecord.php
127182

128183
-
129-
message: "#^Property PhpMyAdmin\\\\ShapeFile\\\\ShapeRecord\\:\\:\\$size \\(int\\) does not accept \\(float\\|int\\)\\.$#"
184+
message: '#^Possibly invalid array key type mixed\.$#'
185+
identifier: offsetAccess.invalidOffset
186+
count: 2
187+
path: src/ShapeRecord.php
188+
189+
-
190+
message: '#^Property PhpMyAdmin\\ShapeFile\\ShapeRecord\:\:\$size \(int\) does not accept \(float\|int\)\.$#'
191+
identifier: assign.propertyType
130192
count: 1
131193
path: src/ShapeRecord.php
132194

133195
-
134-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
196+
message: '#^Parameter \#1 \$value of function count expects array\|Countable, mixed given\.$#'
197+
identifier: argument.type
135198
count: 1
136199
path: tests/ShapeFileTest.php

psalm-baseline.xml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
2+
<files psalm-version="6.13.1@1e3b7f0a8ab32b23197b91107adc0a7ed8a05b51">
33
<file src="src/ShapeFile.php">
4+
<ClassMustBeFinal>
5+
<code><![CDATA[ShapeFile]]></code>
6+
</ClassMustBeFinal>
47
<InvalidPropertyAssignmentValue>
58
<code><![CDATA[$this->shpFile]]></code>
69
<code><![CDATA[$this->shxFile]]></code>
@@ -13,6 +16,12 @@
1316
<code><![CDATA[$shapeType]]></code>
1417
</MixedAssignment>
1518
<PossiblyFalseArgument>
19+
<code><![CDATA[$buff32]]></code>
20+
<code><![CDATA[$buff32]]></code>
21+
<code><![CDATA[$buff32]]></code>
22+
<code><![CDATA[$buff32]]></code>
23+
<code><![CDATA[$buff32]]></code>
24+
<code><![CDATA[$buff32]]></code>
1625
<code><![CDATA[$this->shpFile]]></code>
1726
</PossiblyFalseArgument>
1827
<PossiblyNullOperand>
@@ -30,6 +39,9 @@
3039
</UnusedFunctionCall>
3140
</file>
3241
<file src="src/ShapeRecord.php">
42+
<ClassMustBeFinal>
43+
<code><![CDATA[ShapeRecord]]></code>
44+
</ClassMustBeFinal>
3345
<MixedArgument>
3446
<code><![CDATA[$data['m']]]></code>
3547
<code><![CDATA[$data['m']]]></code>
@@ -142,9 +154,22 @@
142154
<code><![CDATA[$shpFile]]></code>
143155
</PropertyNotSetInConstructor>
144156
</file>
157+
<file src="src/Util.php">
158+
<ClassMustBeFinal>
159+
<code><![CDATA[Util]]></code>
160+
</ClassMustBeFinal>
161+
</file>
145162
<file src="tests/ShapeFileTest.php">
163+
<ClassMustBeFinal>
164+
<code><![CDATA[ShapeFileTest]]></code>
165+
</ClassMustBeFinal>
146166
<MixedArgument>
147167
<code><![CDATA[$shp->records[0]->shpData['parts']]]></code>
148168
</MixedArgument>
149169
</file>
170+
<file src="tests/UtilTest.php">
171+
<ClassMustBeFinal>
172+
<code><![CDATA[UtilTest]]></code>
173+
</ClassMustBeFinal>
174+
</file>
150175
</files>

0 commit comments

Comments
 (0)