From fcbab3b961cfc358691255a15e24b07aadb6c6c6 Mon Sep 17 00:00:00 2001
From: Klaus Purer <klaus.purer@protonmail.ch>
Date: Thu, 2 Jan 2025 13:05:06 +0100
Subject: [PATCH] feat(EmptyPHPStatement): Add sniff for empty PHP statements,
 same as Drupal core does (#3496958)

---
 coder_sniffer/Drupal/ruleset.xml | 13 ++++---------
 tests/Drupal/bad/BadUnitTest.php |  1 +
 tests/Drupal/bad/bad.php.fixed   |  1 -
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/coder_sniffer/Drupal/ruleset.xml b/coder_sniffer/Drupal/ruleset.xml
index 59da63e2..fd3a42b1 100644
--- a/coder_sniffer/Drupal/ruleset.xml
+++ b/coder_sniffer/Drupal/ruleset.xml
@@ -47,16 +47,18 @@
     <exclude-pattern>*.tpl.php</exclude-pattern>
   </rule>
 
+  <!-- Generic sniffs -->
+  <rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
   <rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
   <rule ref="Generic.Files.ByteOrderMark"/>
+  <rule ref="Generic.Files.LineEndings"/>
   <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
   <rule ref="Generic.Formatting.SpaceAfterCast"/>
-
   <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
+  <!-- Already covered by Drupal.WhiteSpace.Comma.NoSpace. -->
   <rule ref="Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma">
     <severity>0</severity>
   </rule>
-
   <rule ref="Generic.NamingConventions.ConstructorName"/>
   <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
   <rule ref="Generic.PHP.DeprecatedFunctions"/>
@@ -65,13 +67,6 @@
   <rule ref="Generic.PHP.UpperCaseConstant"/>
   <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
 
-  <!-- Use Unix newlines -->
-  <rule ref="Generic.Files.LineEndings">
-    <properties>
-      <property name="eolChar" value="\n"/>
-    </properties>
-  </rule>
-
   <rule ref="MySource.Debug.DebugCode"/>
   <rule ref="PEAR.Files.IncludingFile"/>
   <!-- Disable some error messages that we do not want. -->
diff --git a/tests/Drupal/bad/BadUnitTest.php b/tests/Drupal/bad/BadUnitTest.php
index 59811f28..15c4f045 100644
--- a/tests/Drupal/bad/BadUnitTest.php
+++ b/tests/Drupal/bad/BadUnitTest.php
@@ -434,6 +434,7 @@ class BadUnitTest extends CoderSniffUnitTest
                 809 => 1,
                 823 => 1,
                 824 => 1,
+                836 => 1,
             ];
         }//end switch
 
diff --git a/tests/Drupal/bad/bad.php.fixed b/tests/Drupal/bad/bad.php.fixed
index f5fd6185..71ddbb72 100644
--- a/tests/Drupal/bad/bad.php.fixed
+++ b/tests/Drupal/bad/bad.php.fixed
@@ -884,7 +884,6 @@ function test28() {
 
 // Multiple statements on one line are not allowed.
 echo 'Hi!';
-;
 
 /**
  *
-- 
GitLab