Skip to content

Commit 4ce285b

Browse files
committed
Fix tests
1 parent 71e7550 commit 4ce285b

File tree

2 files changed

+133
-60
lines changed

2 files changed

+133
-60
lines changed

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

+124-58
Original file line numberDiff line numberDiff line change
@@ -131,64 +131,130 @@ public function testCallToArrayMapVariadic(): void
131131

132132
public function testCallToWeirdFunctions(): void
133133
{
134-
$this->analyse([__DIR__ . '/data/call-to-weird-functions.php'], [
135-
[
136-
'Function implode invoked with 0 parameters, 1-2 required.',
137-
3,
138-
],
139-
[
140-
'Function implode invoked with 3 parameters, 1-2 required.',
141-
6,
142-
],
143-
[
144-
'Function strtok invoked with 0 parameters, 1-2 required.',
145-
8,
146-
],
147-
[
148-
'Function strtok invoked with 3 parameters, 1-2 required.',
149-
11,
150-
],
151-
[
152-
'Function fputcsv invoked with 1 parameter, 2-5 required.',
153-
12,
154-
],
155-
[
156-
'Function imagepng invoked with 0 parameters, 1-4 required.',
157-
16,
158-
],
159-
[
160-
'Function imagepng invoked with 5 parameters, 1-4 required.',
161-
19,
162-
],
163-
[
164-
'Function locale_get_display_language invoked with 3 parameters, 1-2 required.',
165-
30,
166-
],
167-
[
168-
'Function mysqli_fetch_all invoked with 0 parameters, 1-2 required.',
169-
32,
170-
],
171-
[
172-
'Function mysqli_fetch_all invoked with 3 parameters, 1-2 required.',
173-
35,
174-
],
175-
[
176-
'Function openssl_open invoked with 7 parameters, 4-6 required.',
177-
39,
178-
],
179-
[
180-
'Function openssl_x509_parse invoked with 3 parameters, 1-2 required.',
181-
43,
182-
],
183-
[
184-
'Function openssl_pkcs12_export invoked with 6 parameters, 4-5 required.',
185-
49,
186-
],
187-
[
188-
'Parameter #1 $depth of function xdebug_call_class expects int, string given.',
189-
51,
190-
],
191-
]);
134+
if (PHP_VERSION_ID >= 80000) {
135+
$errors = [
136+
[
137+
'Function implode invoked with 0 parameters, 1-2 required.',
138+
3,
139+
],
140+
[
141+
'Function implode invoked with 3 parameters, 1-2 required.',
142+
6,
143+
],
144+
[
145+
'Function strtok invoked with 0 parameters, 1-2 required.',
146+
8,
147+
],
148+
[
149+
'Function strtok invoked with 3 parameters, 1-2 required.',
150+
11,
151+
],
152+
[
153+
'Function fputcsv invoked with 1 parameter, 2-5 required.',
154+
12,
155+
],
156+
[
157+
'Function imagepng invoked with 0 parameters, 1-4 required.',
158+
16,
159+
],
160+
[
161+
'Function imagepng invoked with 5 parameters, 1-4 required.',
162+
19,
163+
],
164+
[
165+
'Function locale_get_display_language invoked with 3 parameters, 1-2 required.',
166+
30,
167+
],
168+
[
169+
'Function mysqli_fetch_all invoked with 0 parameters, 1-2 required.',
170+
32,
171+
],
172+
[
173+
'Function mysqli_fetch_all invoked with 3 parameters, 1-2 required.',
174+
35,
175+
],
176+
[
177+
'Function openssl_open invoked with 4 parameters, 5-6 required.',
178+
38,
179+
],
180+
[
181+
'Function openssl_open invoked with 7 parameters, 5-6 required.',
182+
39,
183+
],
184+
[
185+
'Function openssl_x509_parse invoked with 3 parameters, 1-2 required.',
186+
43,
187+
],
188+
[
189+
'Function openssl_pkcs12_export invoked with 6 parameters, 4-5 required.',
190+
49,
191+
],
192+
[
193+
'Parameter #1 $depth of function xdebug_call_class expects int, string given.',
194+
51,
195+
],
196+
];
197+
} else {
198+
$errors = [
199+
[
200+
'Function implode invoked with 0 parameters, 1-2 required.',
201+
3,
202+
],
203+
[
204+
'Function implode invoked with 3 parameters, 1-2 required.',
205+
6,
206+
],
207+
[
208+
'Function strtok invoked with 0 parameters, 1-2 required.',
209+
8,
210+
],
211+
[
212+
'Function strtok invoked with 3 parameters, 1-2 required.',
213+
11,
214+
],
215+
[
216+
'Function fputcsv invoked with 1 parameter, 2-5 required.',
217+
12,
218+
],
219+
[
220+
'Function imagepng invoked with 0 parameters, 1-4 required.',
221+
16,
222+
],
223+
[
224+
'Function imagepng invoked with 5 parameters, 1-4 required.',
225+
19,
226+
],
227+
[
228+
'Function locale_get_display_language invoked with 3 parameters, 1-2 required.',
229+
30,
230+
],
231+
[
232+
'Function mysqli_fetch_all invoked with 0 parameters, 1-2 required.',
233+
32,
234+
],
235+
[
236+
'Function mysqli_fetch_all invoked with 3 parameters, 1-2 required.',
237+
35,
238+
],
239+
[
240+
'Function openssl_open invoked with 7 parameters, 4-6 required.',
241+
39,
242+
],
243+
[
244+
'Function openssl_x509_parse invoked with 3 parameters, 1-2 required.',
245+
43,
246+
],
247+
[
248+
'Function openssl_pkcs12_export invoked with 6 parameters, 4-5 required.',
249+
49,
250+
],
251+
[
252+
'Parameter #1 $depth of function xdebug_call_class expects int, string given.',
253+
51,
254+
],
255+
];
256+
}
257+
$this->analyse([__DIR__ . '/data/call-to-weird-functions.php'], $errors);
192258
}
193259

194260
/**

tests/PHPStan/Rules/Methods/MissingMethodParameterTypehintRuleTest.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected function getRule(): \PHPStan\Rules\Rule
1818

1919
public function testRule(): void
2020
{
21-
$this->analyse([__DIR__ . '/data/missing-method-parameter-typehint.php'], [
21+
$errors = [
2222
[
2323
'Method MissingMethodParameterTypehint\FooInterface::getFoo() has parameter $p1 with no typehint specified.',
2424
8,
@@ -64,7 +64,14 @@ public function testRule(): void
6464
119,
6565
'You can turn this off by setting <fg=cyan>checkGenericClassInNonGenericObjectType: false</> in your <fg=cyan>%configurationFile%</>.',
6666
],
67-
]);
67+
];
68+
if (PHP_VERSION_ID >= 80000) {
69+
$errors[] = [
70+
'Method MissingMethodParameterTypehint\SerializableImpl::unserialize() has parameter $serialized with no typehint specified.',
71+
170,
72+
];
73+
}
74+
$this->analyse([__DIR__ . '/data/missing-method-parameter-typehint.php'], $errors);
6875
}
6976

7077
}

0 commit comments

Comments
 (0)