diff --git a/doc/list.rst b/doc/list.rst index 0cf75a0d1eb..d41ae010028 100644 --- a/doc/list.rst +++ b/doc/list.rst @@ -196,7 +196,7 @@ List of Available Rules | Whether there should be a single space after the parenthesis of anonymous class (PSR12) or not. | Allowed types: ``bool`` | Default value: ``false`` - - | ``fix_constructor_arguments`` + - | ``inline_constructor_arguments`` | Whether constructor argument list in anonymous classes should be single line. | Allowed types: ``bool`` | Default value: ``true`` diff --git a/doc/ruleSets/PSR12.rst b/doc/ruleSets/PSR12.rst index 147bc2713d5..a8a6722c2ef 100644 --- a/doc/ruleSets/PSR12.rst +++ b/doc/ruleSets/PSR12.rst @@ -14,7 +14,7 @@ Rules ``['allow_single_line_anonymous_class_with_empty_body' => true]`` - `class_definition <./../rules/class_notation/class_definition.rst>`_ config: - ``['fix_constructor_arguments' => false, 'space_before_parenthesis' => true]`` + ``['inline_constructor_arguments' => false, 'space_before_parenthesis' => true]`` - `compact_nullable_typehint <./../rules/whitespace/compact_nullable_typehint.rst>`_ - `declare_equal_normalize <./../rules/language_construct/declare_equal_normalize.rst>`_ - `lowercase_cast <./../rules/cast_notation/lowercase_cast.rst>`_ diff --git a/doc/rules/class_notation/class_definition.rst b/doc/rules/class_notation/class_definition.rst index 2404ecfe84c..079e87469a7 100644 --- a/doc/rules/class_notation/class_definition.rst +++ b/doc/rules/class_notation/class_definition.rst @@ -45,8 +45,8 @@ Allowed types: ``bool`` Default value: ``false`` -``fix_constructor_arguments`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``inline_constructor_arguments`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Whether constructor argument list in anonymous classes should be single line. @@ -154,7 +154,7 @@ With configuration: ``['space_before_parenthesis' => true]``. Example #6 ~~~~~~~~~~ -With configuration: ``['fix_constructor_arguments' => true]``. +With configuration: ``['inline_constructor_arguments' => true]``. .. code-block:: diff @@ -175,7 +175,7 @@ The rule is part of the following rule sets: @PSR12 Using the `@PSR12 <./../../ruleSets/PSR12.rst>`_ rule set will enable the ``class_definition`` rule with the config below: - ``['fix_constructor_arguments' => false, 'space_before_parenthesis' => true]`` + ``['inline_constructor_arguments' => false, 'space_before_parenthesis' => true]`` @PSR2 Using the `@PSR2 <./../../ruleSets/PSR2.rst>`_ rule set will enable the ``class_definition`` rule with the default config. diff --git a/src/Fixer/ClassNotation/ClassDefinitionFixer.php b/src/Fixer/ClassNotation/ClassDefinitionFixer.php index 89528cd4bdc..936cb00873a 100644 --- a/src/Fixer/ClassNotation/ClassDefinitionFixer.php +++ b/src/Fixer/ClassNotation/ClassDefinitionFixer.php @@ -95,7 +95,7 @@ interface Bar extends ), new CodeSample( " true] + ['inline_constructor_arguments' => true] ), ] ); @@ -155,7 +155,7 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn ->setAllowedTypes(['bool']) ->setDefault(false) ->getOption(), - (new FixerOptionBuilder('fix_constructor_arguments', 'Whether constructor argument list in anonymous classes should be single line.')) + (new FixerOptionBuilder('inline_constructor_arguments', 'Whether constructor argument list in anonymous classes should be single line.')) ->setAllowedTypes(['bool']) ->setDefault(true) ->getOption(), @@ -335,7 +335,7 @@ private function getClassyInheritanceInfo(Tokens $tokens, int $startIndex, strin private function makeClassyDefinitionSingleLine(Tokens $tokens, int $startIndex, int $endIndex): void { for ($i = $endIndex; $i >= $startIndex; --$i) { - if (!$this->configuration['fix_constructor_arguments'] && $tokens[$i]->equals(')')) { + if (!$this->configuration['inline_constructor_arguments'] && $tokens[$i]->equals(')')) { $i = $tokens->findBlockStart(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $i); continue; diff --git a/src/RuleSet/Sets/PSR12Set.php b/src/RuleSet/Sets/PSR12Set.php index 7311ea12502..dd04f4c1e3c 100644 --- a/src/RuleSet/Sets/PSR12Set.php +++ b/src/RuleSet/Sets/PSR12Set.php @@ -30,7 +30,7 @@ public function getRules(): array 'allow_single_line_anonymous_class_with_empty_body' => true, ], 'class_definition' => [ - 'fix_constructor_arguments' => false, // handled by method_argument_space fixer + 'inline_constructor_arguments' => false, // handled by method_argument_space fixer 'space_before_parenthesis' => true, // defined in PSR12 ΒΆ8. Anonymous Classes ], 'compact_nullable_typehint' => true, diff --git a/tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php b/tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php index c3b9a82fa29..294ae6c853e 100644 --- a/tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php +++ b/tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php @@ -34,7 +34,7 @@ public function testConfigureDefaultToFalse(): void 'single_item_single_line' => false, 'single_line' => false, 'space_before_parenthesis' => false, - 'fix_constructor_arguments' => true, + 'inline_constructor_arguments' => true, ]; $fixer = new ClassDefinitionFixer(); @@ -103,7 +103,7 @@ public function testInvalidConfigurationKey(): void { $this->expectException(InvalidFixerConfigurationException::class); $this->expectExceptionMessageMatches( - '/^\[class_definition\] Invalid configuration: The option "a" does not exist\. Defined options are: "fix_constructor_arguments", "multi_line_extends_each_single_line", "single_item_single_line", "single_line", "space_before_parenthesis"\.$/' + '/^\[class_definition\] Invalid configuration: The option "a" does not exist\. Defined options are: "inline_constructor_arguments", "multi_line_extends_each_single_line", "single_item_single_line", "single_line", "space_before_parenthesis"\.$/' ); $fixer = new ClassDefinitionFixer(); @@ -157,12 +157,12 @@ public function provideAnonymousClassesCases(): array [ ' false], + ['inline_constructor_arguments' => false], ], [ 'foo() , bar ( $a) ) {};', "foo() , bar ( \$a) ){};", - ['fix_constructor_arguments' => false], + ['inline_constructor_arguments' => false], ], [ ' false], + ['inline_constructor_arguments' => false], ], [ 'prop ) {};', 'prop ){};', - ['fix_constructor_arguments' => false], + ['inline_constructor_arguments' => false], ], [ 'prop, $v[3], 4) {};', @@ -295,10 +295,10 @@ class# ' true], ], - 'space_before_parenthesis and fix_constructor_arguments' => [ + 'space_before_parenthesis and inline_constructor_arguments' => [ 'bar()) ,baz() ) {};', 'bar()) ,baz() ) {};', - ['space_before_parenthesis' => true, 'fix_constructor_arguments' => false], + ['space_before_parenthesis' => true, 'inline_constructor_arguments' => false], ], ]; }