Skip to content

Commit 6150ffd

Browse files
committed
move non-named arg tests
1 parent 5e9fc22 commit 6150ffd

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎tests/PHPStan/Rules/Functions/ReplaceCountMismatchRuleTest.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public function testBug3889(): void
4848
'Call to preg_filter is using fewer replacements than search values.',
4949
50,
5050
],
51+
[
52+
'Call to str_replace is using fewer replacements than search values.',
53+
53,
54+
],
5155
]);
5256
}
5357

@@ -59,10 +63,6 @@ public function testNamedArgs(): void
5963
'Call to str_replace is using fewer replacements than search values.',
6064
9,
6165
],
62-
[
63-
'Call to str_replace is using fewer replacements than search values.',
64-
14,
65-
],
6666
]);
6767
}
6868

‎tests/PHPStan/Rules/Functions/data/bug-3889-named-args.php‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,4 @@ function doFoo(string $s, bool $b): void
99
str_replace(search: ['a', 'b'], subject: $s, replace: ['x']);
1010
str_replace(search: ['a', 'b'], subject: $s, replace: ['x', 'y']);
1111
str_replace(search: ['a', 'b'], subject: $s, replace: []);
12-
13-
$r = $b ? [] : ['x'];
14-
str_replace(['a', 'b', 'c'], $r, $s);
15-
16-
$r = $b ? ['x'] : ['x', 'y', 'z'];
17-
str_replace(['a', 'b', 'c'], $r, $s);
18-
19-
str_replace(['a', 'b', 'c'], ['x', 'y', 'z'], $s);
2012
}

‎tests/PHPStan/Rules/Functions/data/bug-3889.php‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Variants
2828
* @param array{string, string} $two
2929
* @param array{string, string, string}|array{string} $oneOrThree
3030
*/
31-
public function doFoo(string $s, array $list, array $nonEmptyList, array $two, array $oneOrThree): void
31+
public function doFoo(string $s, array $list, array $nonEmptyList, array $two, array $oneOrThree, bool $b): void
3232
{
3333
// see https://3v4l.org/Ct0Ts#v
3434
str_replace(['a', 'b'], ['x', 'y'], $s);
@@ -48,5 +48,13 @@ public function doFoo(string $s, array $list, array $nonEmptyList, array $two, a
4848
preg_replace(['/a/', '/b/'], ['x', 'y'], $s);
4949
preg_replace(['/a/', '/b/'], 'x', $s);
5050
preg_filter(['/a/', '/b/'], ['x'], $s);
51+
52+
$r = $b ? [] : ['x'];
53+
str_replace(['a', 'b', 'c'], $r, $s);
54+
55+
$r = $b ? ['x'] : ['x', 'y', 'z'];
56+
str_replace(['a', 'b', 'c'], $r, $s);
57+
58+
str_replace(['a', 'b', 'c'], ['x', 'y', 'z'], $s);
5159
}
5260
}

0 commit comments

Comments
 (0)