Skip to content

Commit 950a491

Browse files
committed
Revert "Dumb down parameter types in recently added stubs"
This reverts commit 2d79c62.
1 parent f0a6296 commit 950a491

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

stubs/core.stub

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

224224
/**
225-
* @param string|array<mixed> $pattern
226-
* @param callable(array<int|string, string>):string $callback
227-
* @param string|array<mixed> $subject
225+
* @param string|string[] $pattern
226+
* @param callable(string[]):string $callback
227+
* @param string|array<string|int|float> $subject
228228
* @param int $count
229229
* @param-out 0|positive-int $count
230230
* @return ($subject is array ? list<string>|null : string|null)
231231
*/
232232
function preg_replace_callback($pattern, $callback, $subject, int $limit = -1, &$count = null, int $flags = 0) {}
233233

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

244244
/**
245-
* @param string|array<mixed> $pattern
246-
* @param string|array<mixed> $replacement
247-
* @param string|array<mixed> $subject
245+
* @param string|string[] $pattern
246+
* @param string|array<string|int|float> $replacement
247+
* @param string|array<string|int|float> $subject
248248
* @param int $count
249249
* @param-out 0|positive-int $count
250250
* @return ($subject is array ? list<string> : string|null)
251251
*/
252252
function preg_filter($pattern, $replacement, $subject, int $limit = -1, &$count = null) {}
253253

254254
/**
255-
* @param array<mixed>|string $search
256-
* @param array<mixed>|string $replace
257-
* @param array<mixed>|string $subject
255+
* @param array<string>|string $search
256+
* @param array<string>|string $replace
257+
* @param array<string>|string $subject
258258
* @param-out int $count
259259
* @return list<string>|string
260260
*/
261261
function str_replace($search, $replace, $subject, ?int &$count = null) {}
262262

263263
/**
264-
* @param array<mixed>|string $search
265-
* @param array<mixed>|string $replace
266-
* @param array<mixed>|string $subject
264+
* @param array<string>|string $search
265+
* @param array<string>|string $replace
266+
* @param array<string>|string $subject
267267
* @param-out int $count
268268
* @return list<string>|string
269269
*/

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -654,19 +654,19 @@ public function testPregReplaceCallback(): void
654654
{
655655
$this->analyse([__DIR__ . '/data/preg_replace_callback.php'], [
656656
[
657-
'Parameter #2 $callback of function preg_replace_callback expects callable(array<int|string, string>): string, Closure(string): string given.',
657+
'Parameter #2 $callback of function preg_replace_callback expects callable(array<string>): string, Closure(string): string given.',
658658
6,
659659
],
660660
[
661-
'Parameter #2 $callback of function preg_replace_callback expects callable(array<int|string, string>): string, Closure(string): string given.',
661+
'Parameter #2 $callback of function preg_replace_callback expects callable(array<string>): string, Closure(string): string given.',
662662
13,
663663
],
664664
[
665-
'Parameter #2 $callback of function preg_replace_callback expects callable(array<int|string, string>): string, Closure(array): void given.',
665+
'Parameter #2 $callback of function preg_replace_callback expects callable(array<string>): string, Closure(array): void given.',
666666
20,
667667
],
668668
[
669-
'Parameter #2 $callback of function preg_replace_callback expects callable(array<int|string, string>): string, Closure(): void given.',
669+
'Parameter #2 $callback of function preg_replace_callback expects callable(array<string>): string, Closure(): void given.',
670670
25,
671671
],
672672
]);

0 commit comments

Comments
 (0)