You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (!$nativeArrayType->isIterableAtLeastOnce()->no()) {
67
+
$errorBuilder->tip('Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.');
68
+
}
69
+
}
60
70
return [
61
-
RuleErrorBuilder::message(sprintf(
62
-
$message,
63
-
$arrayType->describe(VerbosityLevel::value()),
64
-
))->build(),
71
+
$errorBuilder->build(),
65
72
];
66
73
}
67
74
@@ -70,21 +77,41 @@ public function processNode(Node $node, Scope $scope): array
70
77
71
78
if ($isSuperType->no()) {
72
79
$message = 'Parameter #1 $array (%s) to function array_filter does not contain falsy values, the array will always stay the same.';
$errorBuilder->tip('Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.');
90
+
}
91
+
}
92
+
73
93
return [
74
-
RuleErrorBuilder::message(sprintf(
75
-
$message,
76
-
$arrayType->describe(VerbosityLevel::value()),
77
-
))->build(),
94
+
$errorBuilder->build(),
78
95
];
79
96
}
80
97
81
98
if ($isSuperType->yes()) {
82
99
$message = 'Parameter #1 $array (%s) to function array_filter contains falsy values only, the result will always be an empty array.';
$errorBuilder->tip('Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.');
Copy file name to clipboardExpand all lines: tests/PHPStan/Rules/Functions/ArrayFilterRuleTest.php
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ protected function getRule(): Rule
20
20
21
21
publicfunctiontestFile(): void
22
22
{
23
+
$tipText = 'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.';
23
24
$expectedErrors = [
24
25
[
25
26
'Parameter #1 $array (array{1, 3}) to function array_filter does not contain falsy values, the array will always stay the same.',
@@ -40,6 +41,7 @@ public function testFile(): void
40
41
[
41
42
'Parameter #1 $array (array<stdClass>) to function array_filter does not contain falsy values, the array will always stay the same.',
42
43
20,
44
+
$tipText,
43
45
],
44
46
[
45
47
'Parameter #1 $array (array{0}) to function array_filter contains falsy values only, the result will always be an empty array.',
@@ -60,6 +62,7 @@ public function testFile(): void
60
62
[
61
63
'Parameter #1 $array (array<false|null>) to function array_filter contains falsy values only, the result will always be an empty array.',
62
64
27,
65
+
$tipText,
63
66
],
64
67
[
65
68
'Parameter #1 $array (array{}) to function array_filter is empty, call has no effect.',
@@ -72,10 +75,13 @@ public function testFile(): void
$tipText = 'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.';
79
+
75
80
$expectedErrors = [
76
81
[
77
82
'Parameter #1 $array (array<class-string>) to function array_filter does not contain falsy values, the array will always stay the same.',
0 commit comments