Skip to content

Ensure that spacing around cases are consistent #169

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

Merged
merged 1 commit into from
Apr 6, 2020
Merged
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
3 changes: 3 additions & 0 deletions lib/Doctrine/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
Expand Down
17 changes: 17 additions & 0 deletions tests/fixed/ControlStructures.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,21 @@ public function spaceAroundMultilineIfs(): void
echo 2;
}
}

public function spacingAroundCasesWithBreakAndReturn(): void
{
switch (true) {
case 1:
throw new InvalidArgumentException();

case 2:
return;

case 3:
break;

case 4:
echo 1;
}
}
}
24 changes: 24 additions & 0 deletions tests/input/ControlStructures.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,28 @@ public function spaceAroundMultilineIfs(): void
echo 2;
}
}

public function spacingAroundCasesWithBreakAndReturn(): void
{
switch (true) {

case 1:

throw new InvalidArgumentException();

case 2:

return;


case 3:

break;

case 4:

echo 1;

}
}
}
9 changes: 5 additions & 4 deletions tests/php-compatibility.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/tests/expected_report.txt b/tests/expected_report.txt
index 1e809f9..4776284 100644
index 1e809f9..490fcbd 100644
--- a/tests/expected_report.txt
+++ b/tests/expected_report.txt
@@ -5,44 +5,48 @@ FILE ERRORS WARNINGS
Expand All @@ -12,7 +12,8 @@ index 1e809f9..4776284 100644
+tests/input/concatenation_spacing.php 49 0
tests/input/constants-no-lsb.php 2 0
tests/input/constants-var.php 4 0
tests/input/ControlStructures.php 17 0
-tests/input/ControlStructures.php 17 0
+tests/input/ControlStructures.php 27 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 @@ -52,10 +53,10 @@ index 1e809f9..4776284 100644
tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
-A TOTAL OF 297 ERRORS AND 0 WARNINGS WERE FOUND IN 36 FILES
+A TOTAL OF 361 ERRORS AND 0 WARNINGS WERE FOUND IN 40 FILES
+A TOTAL OF 371 ERRORS AND 0 WARNINGS WERE FOUND IN 40 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 236 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 296 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 306 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Expand Down