From 5059c631642c99eccaba0462a4495d84493b367c Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Mon, 25 Sep 2023 08:40:25 +0200 Subject: [PATCH] #101 - lowercase keywords (#104) * #101 - lowercase keywords * #101 - fix --- src/Configuration/Defaults/CommonRules.php | 2 ++ tests/codestyle/CommonRulesetTest.php | 1 + tests/fixtures/lowercaseKeywords/actual.php | 22 +++++++++++++++++++ tests/fixtures/lowercaseKeywords/expected.php | 22 +++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 tests/fixtures/lowercaseKeywords/actual.php create mode 100644 tests/fixtures/lowercaseKeywords/expected.php diff --git a/src/Configuration/Defaults/CommonRules.php b/src/Configuration/Defaults/CommonRules.php index 8ce9c01..21e9f49 100644 --- a/src/Configuration/Defaults/CommonRules.php +++ b/src/Configuration/Defaults/CommonRules.php @@ -14,6 +14,7 @@ use PhpCsFixer\Fixer\Basic\NoMultipleStatementsPerLineFixer; use PhpCsFixer\Fixer\Basic\NoTrailingCommaInSinglelineFixer; use PhpCsFixer\Fixer\Basic\PsrAutoloadingFixer; +use PhpCsFixer\Fixer\Casing\LowercaseKeywordsFixer; use PhpCsFixer\Fixer\Casing\LowercaseStaticReferenceFixer; use PhpCsFixer\Fixer\Casing\MagicConstantCasingFixer; use PhpCsFixer\Fixer\Casing\MagicMethodCasingFixer; @@ -328,5 +329,6 @@ class CommonRules extends Rules CurlyBracesPositionFixer::class => [ "anonymous_functions_opening_brace" => "same_line", ], + LowercaseKeywordsFixer::class => true, ]; } diff --git a/tests/codestyle/CommonRulesetTest.php b/tests/codestyle/CommonRulesetTest.php index 2b97ea2..d7fc94d 100644 --- a/tests/codestyle/CommonRulesetTest.php +++ b/tests/codestyle/CommonRulesetTest.php @@ -62,6 +62,7 @@ public static function providePhp80Fixtures(): array ["blankLineBeforeStatement"], ["braces"], ["stringVariables"], + ["lowercaseKeywords"], ]; } diff --git a/tests/fixtures/lowercaseKeywords/actual.php b/tests/fixtures/lowercaseKeywords/actual.php new file mode 100644 index 0000000..98b445e --- /dev/null +++ b/tests/fixtures/lowercaseKeywords/actual.php @@ -0,0 +1,22 @@ + 3) { + Return 0; + } + } + + RETURN 5; + } + + public function testAnonymousClass(): void + { + new Class() EXTENDS LowercaseKeywordsTest {}; + } +} diff --git a/tests/fixtures/lowercaseKeywords/expected.php b/tests/fixtures/lowercaseKeywords/expected.php new file mode 100644 index 0000000..e74fa06 --- /dev/null +++ b/tests/fixtures/lowercaseKeywords/expected.php @@ -0,0 +1,22 @@ + 3) { + return 0; + } + } + + return 5; + } + + public function testAnonymousClass(): void + { + new class() extends LowercaseKeywordsTest {}; + } +}