Browse Source

feat: Add `array_indentation` to `PER-CS2.0` ruleset (#7881)

Vincent Langlet 1 year ago
parent
commit
5cfa1f91f4

+ 1 - 0
doc/ruleSets/PER-CS2.0.rst

@@ -8,6 +8,7 @@ Rules
 -----
 -----
 
 
 - `@PER-CS1.0 <./PER-CS1.0.rst>`_
 - `@PER-CS1.0 <./PER-CS1.0.rst>`_
+- `array_indentation <./../rules/whitespace/array_indentation.rst>`_
 - `cast_spaces <./../rules/cast_notation/cast_spaces.rst>`_
 - `cast_spaces <./../rules/cast_notation/cast_spaces.rst>`_
 - `concat_space <./../rules/operator/concat_space.rst>`_ with config:
 - `concat_space <./../rules/operator/concat_space.rst>`_ with config:
 
 

+ 0 - 1
doc/ruleSets/PhpCsFixer.rst

@@ -9,7 +9,6 @@ Rules
 
 
 - `@PER-CS <./PER-CS.rst>`_
 - `@PER-CS <./PER-CS.rst>`_
 - `@Symfony <./Symfony.rst>`_
 - `@Symfony <./Symfony.rst>`_
-- `array_indentation <./../rules/whitespace/array_indentation.rst>`_
 - `blank_line_before_statement <./../rules/whitespace/blank_line_before_statement.rst>`_ with config:
 - `blank_line_before_statement <./../rules/whitespace/blank_line_before_statement.rst>`_ with config:
 
 
   ``['statements' => ['break', 'case', 'continue', 'declare', 'default', 'exit', 'goto', 'include', 'include_once', 'phpdoc', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'yield', 'yield_from']]``
   ``['statements' => ['break', 'case', 'continue', 'declare', 'default', 'exit', 'goto', 'include', 'include_once', 'phpdoc', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'yield', 'yield_from']]``

+ 5 - 1
doc/rules/whitespace/array_indentation.rst

@@ -27,9 +27,13 @@ Example #1
 Rule sets
 Rule sets
 ---------
 ---------
 
 
-The rule is part of the following rule set:
+The rule is part of the following rule sets:
 
 
+- `@PER <./../../ruleSets/PER.rst>`_
+- `@PER-CS <./../../ruleSets/PER-CS.rst>`_
+- `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
 - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
 - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
+- `@Symfony <./../../ruleSets/Symfony.rst>`_
 
 
 References
 References
 ----------
 ----------

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

@@ -34,6 +34,7 @@ final class PERCS2x0Set extends AbstractRuleSetDescription
     {
     {
         return [
         return [
             '@PER-CS1.0' => true,
             '@PER-CS1.0' => true,
+            'array_indentation' => true,
             'cast_spaces' => true,
             'cast_spaces' => true,
             'concat_space' => ['spacing' => 'one'],
             'concat_space' => ['spacing' => 'one'],
             'function_declaration' => [
             'function_declaration' => [

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

@@ -26,7 +26,6 @@ final class PhpCsFixerSet extends AbstractRuleSetDescription
         return [
         return [
             '@PER-CS' => true,
             '@PER-CS' => true,
             '@Symfony' => true,
             '@Symfony' => true,
-            'array_indentation' => true,
             'blank_line_before_statement' => [
             'blank_line_before_statement' => [
                 'statements' => [
                 'statements' => [
                     'break',
                     'break',

+ 6 - 0
tests/Fixtures/Integration/set/@PER-CS2.0.test-in.php

@@ -43,4 +43,10 @@ $c = true  ? (INT) '1'  :  2;
 
 
 $fn = fn ($a) => $a;
 $fn = fn ($a) => $a;
 
 
+$arrayNotMultiline = ['foo' => 'bar', 'foo2' => 'bar'];
+$arrayMultiline = [
+'foo' => 'bar',
+'foo2' => 'bar',
+];
+
 ?>
 ?>

+ 6 - 0
tests/Fixtures/Integration/set/@PER-CS2.0.test-out.php

@@ -50,3 +50,9 @@ $b = (bool) 1;
 $c = true ? (int) '1' : 2;
 $c = true ? (int) '1' : 2;
 
 
 $fn = fn($a) => $a;
 $fn = fn($a) => $a;
+
+$arrayNotMultiline = ['foo' => 'bar', 'foo2' => 'bar'];
+$arrayMultiline = [
+    'foo' => 'bar',
+    'foo2' => 'bar',
+];