diff --git a/CHANGELOG.md b/CHANGELOG.md index 694dad1..b5dfb4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - add running tests on PHP 8.3 - add rule declare_equal_normalize to support declare(strict_types=1) without spaces around equal for Drupal8 +- enable ordered_imports.case_sensitive by default since Drupal Coder (8.3.25) is now enforcing it ## [2.1.0] - 2023-10-23 ### Added diff --git a/config/drupal/phpcsfixer.rules.yml b/config/drupal/phpcsfixer.rules.yml index 1c78899..766c760 100644 --- a/config/drupal/phpcsfixer.rules.yml +++ b/config/drupal/phpcsfixer.rules.yml @@ -87,6 +87,13 @@ parameters: allow_mixed: true allow_unused_params: true remove_inheritdoc: false + ordered_imports: + case_sensitive: true + imports_order: + - class + - function + - const + sort_algorithm: alpha phpdoc_add_missing_param_annotation: false single_line_comment_style: true single_quote: diff --git a/tests/Integration/Scenario7Test.php b/tests/Integration/Scenario7Test.php new file mode 100644 index 0000000..8cf6dfa --- /dev/null +++ b/tests/Integration/Scenario7Test.php @@ -0,0 +1,42 @@ + + * + * Covers the PHP-CS-Fixer rules ordered_imports.case_sensitive + * + * @internal + */ +final class Scenario7Test extends IntegrationTestCase +{ + protected function getScenarioPath(): string + { + return __DIR__ . '/fixtures/scenario7'; + } + + public function testDrupal8Config(): void + { + $drupal8 = new Drupal8(); + $rules = $drupal8->getRules(); + $ruleset = new RuleSet($rules); + + $factory = (new FixerFactory()) + ->registerBuiltInFixers() + ->registerCustomFixers($drupal8->getCustomFixers()) + ->useRuleSet($ruleset); + + $fixers = []; + foreach ($factory->getFixers() as $fixer) { + $fixers[$fixer->getName()] = $fixer; + } + + $this->doTest($fixers); + } +} diff --git a/tests/Integration/fixtures/scenario7/bad.php b/tests/Integration/fixtures/scenario7/bad.php new file mode 100644 index 0000000..f3a6dd2 --- /dev/null +++ b/tests/Integration/fixtures/scenario7/bad.php @@ -0,0 +1,16 @@ + 'alpha', ], 'ordered_imports' => [ + 'case_sensitive' => true, 'imports_order' => [ 0 => 'class', 1 => 'function', diff --git a/tests/Unit/Config/Drupal8Test.php b/tests/Unit/Config/Drupal8Test.php index e8f65b3..106178d 100644 --- a/tests/Unit/Config/Drupal8Test.php +++ b/tests/Unit/Config/Drupal8Test.php @@ -316,6 +316,7 @@ public function testConfigDefault(): void 'sort_algorithm' => 'alpha', ], 'ordered_imports' => [ + 'case_sensitive' => true, 'imports_order' => [ 0 => 'class', 1 => 'function',