-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from rodrigoprimo/test-coverage-for-loop-shou…
…ld-be-while-loop Generic/ForLoopShouldBeWhileLoop: improve sniff code coverage + fix potential PHP 8.3 deprecation notice
- Loading branch information
Showing
6 changed files
with
61 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.1.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
for ($i = 0; $i < 10; $i++) { | ||
// Everything is fine | ||
} | ||
|
||
for (; $it->valid();) { | ||
$it->next(); | ||
} | ||
|
||
for (;(($it1->valid() && $foo) || (!$it2->value && ($bar || false)));/*Could be ignored*/) { | ||
$it1->next(); | ||
$it2->next(); | ||
} | ||
|
||
for ($i = 0, $j = 10; $i < $j; $i++, $j--) { | ||
echo "i: $i, j: $j\n"; | ||
} | ||
|
||
for (;;) { | ||
if ($i >= 10) { | ||
break; | ||
} | ||
echo $i++; | ||
} | ||
|
||
for ($i = 0; $i < 10; $i++): ?> | ||
<p><?php echo $i; ?></p> | ||
<?php endfor; | ||
|
||
for ($i = 0, $len = count($array); $i < $len; $i++): | ||
echo $array[$i]; | ||
endfor; | ||
|
||
for (; $i < 10;): | ||
echo $i; | ||
$i++; | ||
endfor; |
4 changes: 4 additions & 0 deletions
4
src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.2.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
6 changes: 6 additions & 0 deletions
6
src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.3.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
// Issue PHPCSStandards/PHP_CodeSniffer#226 | ||
// Intentional parse error (missing close parenthesis). Testing that the sniff is *not* triggered | ||
// in this case and that no PHP 8.3+ deprecation notice is thrown. | ||
for ($i = 0; $i < 10; $i++ |
13 changes: 0 additions & 13 deletions
13
src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.inc
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters