Skip to content

Commit b29a267

Browse files
committed
Change error messages to my taste
1 parent 7627b52 commit b29a267

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Rules/Functions/ArrayFilterRule.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function processNode(Node $node, Scope $scope): array
6262
$isSuperType = $falsyType->isSuperTypeOf($arrayType->getIterableValueType());
6363

6464
if ($isSuperType->no()) {
65-
$message = 'Parameter #1 $array (%s) to function array_filter cannot contain empty values, call has no effect.';
65+
$message = 'Parameter #1 $array (%s) to function array_filter does not contain falsy values, the array will always stay the same.';
6666
return [
6767
RuleErrorBuilder::message(sprintf(
6868
$message,
@@ -72,7 +72,7 @@ public function processNode(Node $node, Scope $scope): array
7272
}
7373

7474
if ($isSuperType->yes()) {
75-
$message = 'Parameter #1 $array (%s) to function array_filter can only contain empty values, call always results in [].';
75+
$message = 'Parameter #1 $array (%s) to function array_filter contains falsy values only, the result will always be an empty array.';
7676
return [
7777
RuleErrorBuilder::message(sprintf(
7878
$message,

tests/PHPStan/Rules/Functions/ArrayFilterRuleTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,43 +20,43 @@ public function testFile(): void
2020
{
2121
$expectedErrors = [
2222
[
23-
'Parameter #1 $array (array{1, 3}) to function array_filter cannot contain empty values, call has no effect.',
23+
'Parameter #1 $array (array{1, 3}) to function array_filter does not contain falsy values, the array will always stay the same.',
2424
11,
2525
],
2626
[
27-
'Parameter #1 $array (array{\'test\'}) to function array_filter cannot contain empty values, call has no effect.',
27+
'Parameter #1 $array (array{\'test\'}) to function array_filter does not contain falsy values, the array will always stay the same.',
2828
12,
2929
],
3030
[
31-
'Parameter #1 $array (array{true, true}) to function array_filter cannot contain empty values, call has no effect.',
31+
'Parameter #1 $array (array{true, true}) to function array_filter does not contain falsy values, the array will always stay the same.',
3232
17,
3333
],
3434
[
35-
'Parameter #1 $array (array{stdClass}) to function array_filter cannot contain empty values, call has no effect.',
35+
'Parameter #1 $array (array{stdClass}) to function array_filter does not contain falsy values, the array will always stay the same.',
3636
18,
3737
],
3838
[
39-
'Parameter #1 $array (array<stdClass>) to function array_filter cannot contain empty values, call has no effect.',
39+
'Parameter #1 $array (array<stdClass>) to function array_filter does not contain falsy values, the array will always stay the same.',
4040
20,
4141
],
4242
[
43-
'Parameter #1 $array (array{0}) to function array_filter can only contain empty values, call always results in [].',
43+
'Parameter #1 $array (array{0}) to function array_filter contains falsy values only, the result will always be an empty array.',
4444
23,
4545
],
4646
[
47-
'Parameter #1 $array (array{null}) to function array_filter can only contain empty values, call always results in [].',
47+
'Parameter #1 $array (array{null}) to function array_filter contains falsy values only, the result will always be an empty array.',
4848
24,
4949
],
5050
[
51-
'Parameter #1 $array (array{null, null}) to function array_filter can only contain empty values, call always results in [].',
51+
'Parameter #1 $array (array{null, null}) to function array_filter contains falsy values only, the result will always be an empty array.',
5252
25,
5353
],
5454
[
55-
'Parameter #1 $array (array{null, 0}) to function array_filter can only contain empty values, call always results in [].',
55+
'Parameter #1 $array (array{null, 0}) to function array_filter contains falsy values only, the result will always be an empty array.',
5656
26,
5757
],
5858
[
59-
'Parameter #1 $array (array<false|null>) to function array_filter can only contain empty values, call always results in [].',
59+
'Parameter #1 $array (array<false|null>) to function array_filter contains falsy values only, the result will always be an empty array.',
6060
27,
6161
],
6262
[

0 commit comments

Comments
 (0)