Skip to content

Commit 3b2f88f

Browse files
committed
Generic/NoSilencedErrors: improve test coverage
This commit adds two new tests to cover lines of the Generic.PHP.NoSiliencedErrors that were not covered previously. One has to do with a sniff property that allows users to set this sniff as an error instead of a warning (default value) and the other with calculating $contextLength when its value should be smaller than the default value of 4.
1 parent be32eca commit 3b2f88f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ if (@in_array($array, $needle))
88
}
99

1010
$hasValue = @in_array(haystack: $array, needle: $needle);
11+
12+
// phpcs:set Generic.PHP.NoSilencedErrors error true
13+
$fileContent = @file_get_contents('non_existent_file.txt');
14+
// phpcs:set Generic.PHP.NoSilencedErrors error false
15+
16+
echo @$undefinedVariable;

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class NoSilencedErrorsUnitTest extends AbstractSniffUnitTest
3030
*/
3131
public function getErrorList()
3232
{
33-
return [];
33+
return [13 => 1];
3434

3535
}//end getErrorList()
3636

@@ -48,6 +48,7 @@ public function getWarningList()
4848
return [
4949
5 => 1,
5050
10 => 1,
51+
16 => 1,
5152
];
5253

5354
}//end getWarningList()

0 commit comments

Comments
 (0)