Skip to content

Commit 2d79c62

Browse files
committed
Dumb down parameter types in recently added stubs
1 parent 74b70ab commit 2d79c62

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

Diff for: stubs/core.stub

+15-15
Original file line numberDiff line numberDiff line change
@@ -211,48 +211,48 @@ function preg_match_all($pattern, $subject, &$matches = [], int $flags = 1, int
211211
function preg_match($pattern, $subject, &$matches = [], int $flags = 0, int $offset = 0) {}
212212

213213
/**
214-
* @param string|string[] $pattern
215-
* @param callable(string[]):string $callback
216-
* @param string|array<string|int|float> $subject
214+
* @param string|array<mixed> $pattern
215+
* @param callable(array<int|string, string>):string $callback
216+
* @param string|array<mixed> $subject
217217
* @param int $count
218218
* @param-out 0|positive-int $count
219219
* @return ($subject is array ? list<string>|null : string|null)
220220
*/
221221
function preg_replace_callback($pattern, $callback, $subject, int $limit = -1, &$count = null, int $flags = 0) {}
222222

223223
/**
224-
* @param string|string[] $pattern
225-
* @param string|array<string|int|float> $replacement
226-
* @param string|array<string|int|float> $subject
224+
* @param string|array<mixed> $pattern
225+
* @param string|array<mixed> $replacement
226+
* @param string|array<mixed> $subject
227227
* @param int $count
228228
* @param-out 0|positive-int $count
229229
* @return ($subject is array ? list<string>|null : string|null)
230230
*/
231231
function preg_replace($pattern, $replacement, $subject, int $limit = -1, &$count = null) {}
232232

233233
/**
234-
* @param string|string[] $pattern
235-
* @param string|array<string|int|float> $replacement
236-
* @param string|array<string|int|float> $subject
234+
* @param string|array<mixed> $pattern
235+
* @param string|array<mixed> $replacement
236+
* @param string|array<mixed> $subject
237237
* @param int $count
238238
* @param-out 0|positive-int $count
239239
* @return ($subject is array ? list<string> : string|null)
240240
*/
241241
function preg_filter($pattern, $replacement, $subject, int $limit = -1, &$count = null) {}
242242

243243
/**
244-
* @param array<string>|string $search
245-
* @param array<string>|string $replace
246-
* @param array<string>|string $subject
244+
* @param array<mixed>|string $search
245+
* @param array<mixed>|string $replace
246+
* @param array<mixed>|string $subject
247247
* @param-out int $count
248248
* @return list<string>|string
249249
*/
250250
function str_replace($search, $replace, $subject, int &$count = null) {}
251251

252252
/**
253-
* @param array<string>|string $search
254-
* @param array<string>|string $replace
255-
* @param array<string>|string $subject
253+
* @param array<mixed>|string $search
254+
* @param array<mixed>|string $replace
255+
* @param array<mixed>|string $subject
256256
* @param-out int $count
257257
* @return list<string>|string
258258
*/

Diff for: tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -648,19 +648,19 @@ public function testPregReplaceCallback(): void
648648
{
649649
$this->analyse([__DIR__ . '/data/preg_replace_callback.php'], [
650650
[
651-
'Parameter #2 $callback of function preg_replace_callback expects callable(array<string>): string, Closure(string): string given.',
651+
'Parameter #2 $callback of function preg_replace_callback expects callable(array<int|string, string>): string, Closure(string): string given.',
652652
6,
653653
],
654654
[
655-
'Parameter #2 $callback of function preg_replace_callback expects callable(array<string>): string, Closure(string): string given.',
655+
'Parameter #2 $callback of function preg_replace_callback expects callable(array<int|string, string>): string, Closure(string): string given.',
656656
13,
657657
],
658658
[
659-
'Parameter #2 $callback of function preg_replace_callback expects callable(array<string>): string, Closure(array): void given.',
659+
'Parameter #2 $callback of function preg_replace_callback expects callable(array<int|string, string>): string, Closure(array): void given.',
660660
20,
661661
],
662662
[
663-
'Parameter #2 $callback of function preg_replace_callback expects callable(array<string>): string, Closure(): void given.',
663+
'Parameter #2 $callback of function preg_replace_callback expects callable(array<int|string, string>): string, Closure(): void given.',
664664
25,
665665
],
666666
]);

0 commit comments

Comments
 (0)