Skip to content

Commit

Permalink
Merge pull request PHPCSStandards#163 from rodrigoprimo/update-assign…
Browse files Browse the repository at this point in the history
…ement-in-condition-code-coverage

Generic/AssignmentInCondition: improve sniff code coverage
  • Loading branch information
jrfnl committed Dec 14, 2023
2 parents 186814f + 1fad6ab commit 88d3cec
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

// Intentional parse error. Testing that the sniff is *not* triggered in this case.
if ($a == 123
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

// Intentional parse error. Testing that the sniff is *not* triggered in this case.
for ($i = 0; $i == 100; $i++
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

// Intentional parse error. Testing that the sniff is *not* triggered in this case.
for ($i = 0) {
echo 'foo';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

// Intentional parse error. Testing that the sniff is *not* triggered in this case.
for ($i = 0; $i == 100) {
echo 'foo';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

// Intentional parse error. Testing that the sniff is *not* triggered in this case.
switch ( true ) {
case $sample == 'something'
Original file line number Diff line number Diff line change
Expand Up @@ -41,46 +41,54 @@ public function getErrorList()
* The key of the array should represent the line number and the value
* should represent the number of warnings that should occur on that line.
*
* @param string $testFile The name of the file being tested.
*
* @return array<int, int>
*/
public function getWarningList()
public function getWarningList($testFile='')
{
return [
46 => 1,
47 => 1,
48 => 1,
49 => 1,
50 => 1,
51 => 1,
52 => 1,
53 => 1,
54 => 1,
55 => 1,
56 => 1,
57 => 1,
58 => 1,
59 => 1,
60 => 1,
61 => 2,
63 => 1,
64 => 1,
67 => 1,
68 => 1,
69 => 1,
70 => 1,
71 => 1,
72 => 1,
73 => 1,
75 => 1,
77 => 1,
80 => 2,
84 => 1,
85 => 2,
88 => 1,
90 => 1,
92 => 1,
95 => 1,
];
switch ($testFile) {
case 'AssignmentInConditionUnitTest.1.inc':
return [
46 => 1,
47 => 1,
48 => 1,
49 => 1,
50 => 1,
51 => 1,
52 => 1,
53 => 1,
54 => 1,
55 => 1,
56 => 1,
57 => 1,
58 => 1,
59 => 1,
60 => 1,
61 => 2,
63 => 1,
64 => 1,
67 => 1,
68 => 1,
69 => 1,
70 => 1,
71 => 1,
72 => 1,
73 => 1,
75 => 1,
77 => 1,
80 => 2,
84 => 1,
85 => 2,
88 => 1,
90 => 1,
92 => 1,
95 => 1,
];

default:
return [];
}//end switch

}//end getWarningList()

Expand Down

0 comments on commit 88d3cec

Please sign in to comment.