Skip to content

Commit 5b1cf55

Browse files
committed
feat(EmptyPHPStatement): Add sniff for empty PHP statements, same as Drupal core does
1 parent 36ca8ba commit 5b1cf55

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

coder_sniffer/Drupal/ruleset.xml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,18 @@
4747
<exclude-pattern>*.tpl.php</exclude-pattern>
4848
</rule>
4949

50+
<!-- Generic sniffs -->
51+
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
5052
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
5153
<rule ref="Generic.Files.ByteOrderMark"/>
54+
<rule ref="Generic.Files.LineEndings"/>
5255
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
5356
<rule ref="Generic.Formatting.SpaceAfterCast"/>
54-
5557
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
58+
<!-- Already covered by Drupal.WhiteSpace.Comma.NoSpace. -->
5659
<rule ref="Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma">
5760
<severity>0</severity>
5861
</rule>
59-
6062
<rule ref="Generic.NamingConventions.ConstructorName"/>
6163
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
6264
<rule ref="Generic.PHP.DeprecatedFunctions"/>
@@ -65,13 +67,6 @@
6567
<rule ref="Generic.PHP.UpperCaseConstant"/>
6668
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
6769

68-
<!-- Use Unix newlines -->
69-
<rule ref="Generic.Files.LineEndings">
70-
<properties>
71-
<property name="eolChar" value="\n"/>
72-
</properties>
73-
</rule>
74-
7570
<rule ref="MySource.Debug.DebugCode"/>
7671
<rule ref="PEAR.Files.IncludingFile"/>
7772
<!-- Disable some error messages that we do not want. -->

tests/Drupal/bad/BadUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ protected function getWarningList(string $testFile): array
434434
809 => 1,
435435
823 => 1,
436436
824 => 1,
437+
836 => 1,
437438
];
438439
}//end switch
439440

tests/Drupal/bad/bad.php.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,6 @@ function test28() {
884884

885885
// Multiple statements on one line are not allowed.
886886
echo 'Hi!';
887-
;
888887

889888
/**
890889
*

0 commit comments

Comments
 (0)