Browse Source

PSR12 - ClassDefinition - space_before_parenthesis

SpacePossum 3 years ago
parent
commit
d305690f2d

+ 3 - 0
doc/ruleSets/PSR12.rst

@@ -12,6 +12,9 @@ Rules
 - `braces <./../rules/basic/braces.rst>`_
   config:
   ``['allow_single_line_anonymous_class_with_empty_body' => true]``
+- `class_definition <./../rules/class_notation/class_definition.rst>`_
+  config:
+  ``['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>`_

+ 3 - 1
doc/rules/class_notation/class_definition.rst

@@ -159,7 +159,9 @@ Rule sets
 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 default config.
+  Using the `@PSR12 <./../../ruleSets/PSR12.rst>`_ rule set will enable the ``class_definition`` rule with the config below:
+
+  ``['space_before_parenthesis' => true]``
 
 @PSR2
   Using the `@PSR2 <./../../ruleSets/PSR2.rst>`_ rule set will enable the ``class_definition`` rule with the default config.

+ 1 - 0
src/RuleSet/Sets/PSR12Set.php

@@ -29,6 +29,7 @@ final class PSR12Set extends AbstractRuleSetDescription
             'braces' => [
                 'allow_single_line_anonymous_class_with_empty_body' => true,
             ],
+            'class_definition' => ['space_before_parenthesis' => true], // defined in PSR2 ¶8. Anonymous Classes
             'compact_nullable_typehint' => true,
             'declare_equal_normalize' => true,
             'lowercase_cast' => true,

+ 1 - 1
tests/Fixtures/Integration/set/@PSR12_php70.test-out.php

@@ -6,4 +6,4 @@ function foo(): void
 {
 }
 
-$class = new class() {};
+$class = new class () {};