From acc55a9835a2e86eaa2b630b35892ea8bb6086f0 Mon Sep 17 00:00:00 2001
From: nLightened Development LLC <nic@nlightened.net>
Date: Tue, 31 Dec 2024 04:47:49 -0500
Subject: [PATCH] fix(ScopeIndent): Support PHP attributes (#3461148 by
 nicxvan)

---
 .../Sniffs/WhiteSpace/ScopeIndentSniff.php    |  1 +
 .../Drupal/WhiteSpace/ScopeIndentUnitTest.inc | 19 +++++++++++++++++++
 .../WhiteSpace/ScopeIndentUnitTest.inc.fixed  | 19 +++++++++++++++++++
 3 files changed, 39 insertions(+)

diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php
index 6da012eb..f2b04020 100644
--- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php
+++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php
@@ -962,6 +962,7 @@ class ScopeIndentSniff implements Sniff
                             T_OPEN_CURLY_BRACKET,
                             T_COLON,
                             T_OPEN_TAG,
+                            T_ATTRIBUTE_END,
                         ]
                     ) === false
                     ) {
diff --git a/tests/Drupal/WhiteSpace/ScopeIndentUnitTest.inc b/tests/Drupal/WhiteSpace/ScopeIndentUnitTest.inc
index 582df387..7b753fd1 100644
--- a/tests/Drupal/WhiteSpace/ScopeIndentUnitTest.inc
+++ b/tests/Drupal/WhiteSpace/ScopeIndentUnitTest.inc
@@ -203,3 +203,22 @@ $has_index_value_scalar['foo']['value'] = array (
 EXPECTED
   ],
 ];
+
+/**
+ * Test PHP attributes.
+ */
+class TestPhpAttributes {
+
+  /**
+   * Bar property.
+   */
+  #[NotBlank]
+    private bool $bar;
+
+  /**
+   * Tests method with PHP attribute and docblock.
+   */
+  #[\ReturnTypeWillChange]
+    public function attributes(): void {}
+
+}
diff --git a/tests/Drupal/WhiteSpace/ScopeIndentUnitTest.inc.fixed b/tests/Drupal/WhiteSpace/ScopeIndentUnitTest.inc.fixed
index 4c74f205..a1b3fa4d 100644
--- a/tests/Drupal/WhiteSpace/ScopeIndentUnitTest.inc.fixed
+++ b/tests/Drupal/WhiteSpace/ScopeIndentUnitTest.inc.fixed
@@ -215,3 +215,22 @@ $has_index_value_scalar['foo']['value'] = array (
 EXPECTED
   ],
 ];
+
+/**
+ * Test PHP attributes.
+ */
+class TestPhpAttributes {
+
+  /**
+   * Bar property.
+   */
+  #[NotBlank]
+  private bool $bar;
+
+  /**
+   * Tests method with PHP attribute and docblock.
+   */
+  #[\ReturnTypeWillChange]
+  public function attributes(): void {}
+
+}
-- 
GitLab