Skip to content

Add a test case with switch cases containing return #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/expected_report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tests/input/class-references.php 10 0
tests/input/concatenation_spacing.php 24 0
tests/input/constants-no-lsb.php 2 0
tests/input/constants-var.php 4 0
tests/input/ControlStructures.php 13 0
tests/input/ControlStructures.php 14 0
tests/input/doc-comment-spacing.php 10 0
tests/input/duplicate-assignment-variable.php 1 0
tests/input/EarlyReturn.php 6 0
Expand Down Expand Up @@ -39,9 +39,9 @@ tests/input/use-ordering.php 1 0
tests/input/useless-semicolon.php 2 0
tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
A TOTAL OF 292 ERRORS AND 0 WARNINGS WERE FOUND IN 35 FILES
A TOTAL OF 293 ERRORS AND 0 WARNINGS WERE FOUND IN 35 FILES
----------------------------------------------------------------------
PHPCBF CAN FIX 231 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
PHPCBF CAN FIX 232 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


16 changes: 16 additions & 0 deletions tests/fixed/ControlStructures.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ public function noSpaceAroundCase() : void
}
}

public function noSpaceAfterReturn() : void
{
switch (self::VERSION) {
case 1:
return;
case 2:
// do something
return;
case 3:
$var = 1;

return;
default:
}
}

public function spaceBelowBlocks() : void
{
if (true) {
Expand Down
15 changes: 15 additions & 0 deletions tests/input/ControlStructures.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ public function noSpaceAroundCase() : void
}
}

public function noSpaceAfterReturn() : void
{
switch (self::VERSION) {
case 1:
return;
case 2:
// do something
return;
case 3:
$var = 1;
return;
default:
}
}

public function spaceBelowBlocks() : void
{
if (true) {
Expand Down
10 changes: 5 additions & 5 deletions tests/php-compatibility.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ diff --git a/tests/expected_report.txt b/tests/expected_report.txt
index 11b8d1c..5072a64 100644
--- a/tests/expected_report.txt
+++ b/tests/expected_report.txt
@@ -13,7 +13,7 @@ tests/input/ControlStructures.php 13 0
@@ -13,7 +13,7 @@ tests/input/ControlStructures.php 14 0
tests/input/doc-comment-spacing.php 10 0
tests/input/duplicate-assignment-variable.php 1 0
tests/input/EarlyReturn.php 6 0
Expand All @@ -22,11 +22,11 @@ index 11b8d1c..5072a64 100644
tests/input/useless-semicolon.php 2 0
tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
-A TOTAL OF 292 ERRORS AND 0 WARNINGS WERE FOUND IN 35 FILES
+A TOTAL OF 296 ERRORS AND 0 WARNINGS WERE FOUND IN 35 FILES
-A TOTAL OF 293 ERRORS AND 0 WARNINGS WERE FOUND IN 35 FILES
+A TOTAL OF 297 ERRORS AND 0 WARNINGS WERE FOUND IN 35 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 231 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 235 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 232 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 236 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Expand Down