From 5759956f721c913b350df05436cd5562c60cb8e2 Mon Sep 17 00:00:00 2001 From: Marek Date: Fri, 16 Aug 2024 14:28:59 +0200 Subject: [PATCH] Generic.PHP.LowerCaseKeyword: require lowercase anonymous class keyword --- src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php | 1 + src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc | 4 ++++ .../Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc.fixed | 4 ++++ src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php | 2 ++ 4 files changed, 11 insertions(+) diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php index 1a36917171..4edcc5d92b 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php @@ -27,6 +27,7 @@ public function register() { $targets = Tokens::$contextSensitiveKeywords; $targets += [ + T_ANON_CLASS => T_ANON_CLASS, T_CLOSURE => T_CLOSURE, T_EMPTY => T_EMPTY, T_ENUM_CASE => T_ENUM_CASE, diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc index 37579d3217..429ddebddf 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc +++ b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc @@ -44,5 +44,9 @@ EnuM ENUM: string Case HEARTS; } +new Class {}; +new clasS extends stdClass {}; +new class {}; + __HALT_COMPILER(); // An exception due to phar support. function diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc.fixed b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc.fixed index 7063327ae8..2d68e55a2c 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc.fixed @@ -44,5 +44,9 @@ enum ENUM: string case HEARTS; } +new class {}; +new class extends stdClass {}; +new class {}; + __HALT_COMPILER(); // An exception due to phar support. function diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php index 17f0e25d3e..c2f8831e47 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php @@ -48,6 +48,8 @@ public function getErrorList() 39 => 2, 42 => 1, 44 => 1, + 47 => 1, + 48 => 1, ]; }//end getErrorList()