Skip to content

Commit 4cb3d16

Browse files
committed
PHP 8.0 | Generic/NoSilencedErrors: add tests with named function call parameters
... to confirm that the code snippet in the error message will be correct (set the `$contextLength` to a higher value to confirm).
1 parent 377a467 commit 4cb3d16

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function process(File $phpcsFile, $stackPtr)
5555
{
5656
// Prepare the "Found" string to display.
5757
$contextLength = 4;
58-
$endOfStatement = $phpcsFile->findEndOfStatement($stackPtr, T_COMMA);
58+
$endOfStatement = $phpcsFile->findEndOfStatement($stackPtr, [T_COMMA, T_COLON]);
5959
if (($endOfStatement - $stackPtr) < $contextLength) {
6060
$contextLength = ($endOfStatement - $stackPtr);
6161
}

src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ if (@in_array($array, $needle))
66
{
77
echo '@';
88
}
9-
?>
9+
10+
$hasValue = @in_array(haystack: $array, needle: $needle);

src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ public function getErrorList()
4040
*/
4141
public function getWarningList()
4242
{
43-
return [5 => 1];
43+
return [
44+
5 => 1,
45+
10 => 1,
46+
];
4447

4548
}//end getWarningList()
4649

0 commit comments

Comments
 (0)