Browse Source

Add/Change PHP.MigrationSet to update array/list syntax to short one

Dariusz Ruminski 4 years ago
parent
commit
1f0c53bd3a

+ 12 - 0
doc/ruleSets/PHP54Migration.rst

@@ -0,0 +1,12 @@
+============================
+Rule set ``@PHP54Migration``
+============================
+
+Rules to improve code for PHP 5.6 compatibility.
+
+Rules
+-----
+
+- `array_syntax <./../rules/array_notation/array_syntax.rst>`_
+  config:
+  ``['syntax' => 'short']``

+ 4 - 1
doc/ruleSets/PHP56Migration.rst

@@ -4,4 +4,7 @@ Rule set ``@PHP56Migration``
 
 
 Rules to improve code for PHP 5.6 compatibility.
 Rules to improve code for PHP 5.6 compatibility.
 
 
-This is an empty set.
+Rules
+-----
+
+- `@PHP54Migration <./PHP54Migration.rst>`_

+ 3 - 0
doc/ruleSets/PHP71Migration.rst

@@ -8,6 +8,9 @@ Rules
 -----
 -----
 
 
 - `@PHP70Migration <./PHP70Migration.rst>`_
 - `@PHP70Migration <./PHP70Migration.rst>`_
+- `list_syntax <./../rules/list_notation/list_syntax.rst>`_
+  config:
+  ``['syntax' => 'short']``
 - `visibility_required <./../rules/class_notation/visibility_required.rst>`_
 - `visibility_required <./../rules/class_notation/visibility_required.rst>`_
   config:
   config:
   ``['elements' => ['const', 'method', 'property']]``
   ``['elements' => ['const', 'method', 'property']]``

+ 1 - 1
doc/ruleSets/PSR12.rst

@@ -2,7 +2,7 @@
 Rule set ``@PSR12``
 Rule set ``@PSR12``
 ===================
 ===================
 
 
-Rules that follow `PSR-2 <https://www.php-fig.org/psr/psr-2/>`_ standard.
+Rules that follow `PSR-12 <https://www.php-fig.org/psr/psr-12/>`_ standard.
 
 
 Rules
 Rules
 -----
 -----

+ 1 - 1
doc/ruleSets/PSR12Risky.rst

@@ -2,7 +2,7 @@
 Rule set ``@PSR12:risky``
 Rule set ``@PSR12:risky``
 =========================
 =========================
 
 
-Rules that follow `PSR-2 <https://www.php-fig.org/psr/psr-2/>`_ standard. This set contains rules that are risky.
+Rules that follow `PSR-12 <https://www.php-fig.org/psr/psr-12/>`_ standard. This set contains rules that are risky.
 
 
 Rules
 Rules
 -----
 -----

+ 1 - 0
doc/ruleSets/index.rst

@@ -2,6 +2,7 @@
 List of Available Rule sets
 List of Available Rule sets
 ===========================
 ===========================
 - `@DoctrineAnnotation <./DoctrineAnnotation.rst>`_
 - `@DoctrineAnnotation <./DoctrineAnnotation.rst>`_
+- `@PHP54Migration <./PHP54Migration.rst>`_
 - `@PHP56Migration <./PHP56Migration.rst>`_
 - `@PHP56Migration <./PHP56Migration.rst>`_
 - `@PHP56Migration:risky <./PHP56MigrationRisky.rst>`_
 - `@PHP56Migration:risky <./PHP56MigrationRisky.rst>`_
 - `@PHP70Migration <./PHP70Migration.rst>`_
 - `@PHP70Migration <./PHP70Migration.rst>`_

+ 35 - 0
doc/rules/array_notation/array_syntax.rst

@@ -52,6 +52,41 @@ Rule sets
 
 
 The rule is part of the following rule sets:
 The rule is part of the following rule sets:
 
 
+@PHP54Migration
+  Using the `@PHP54Migration <./../../ruleSets/PHP54Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
+
+  ``['syntax' => 'short']``
+
+@PHP56Migration
+  Using the `@PHP56Migration <./../../ruleSets/PHP56Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
+
+  ``['syntax' => 'short']``
+
+@PHP70Migration
+  Using the `@PHP70Migration <./../../ruleSets/PHP70Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
+
+  ``['syntax' => 'short']``
+
+@PHP71Migration
+  Using the `@PHP71Migration <./../../ruleSets/PHP71Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
+
+  ``['syntax' => 'short']``
+
+@PHP73Migration
+  Using the `@PHP73Migration <./../../ruleSets/PHP73Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
+
+  ``['syntax' => 'short']``
+
+@PHP74Migration
+  Using the `@PHP74Migration <./../../ruleSets/PHP74Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
+
+  ``['syntax' => 'short']``
+
+@PHP80Migration
+  Using the `@PHP80Migration <./../../ruleSets/PHP80Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
+
+  ``['syntax' => 'short']``
+
 @PhpCsFixer
 @PhpCsFixer
   Using the `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
   Using the `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
 
 

+ 25 - 0
doc/rules/list_notation/list_syntax.rst

@@ -47,3 +47,28 @@ With configuration: ``['syntax' => 'short']``.
     <?php
     <?php
    -list($sample) = $array;
    -list($sample) = $array;
    +[$sample] = $array;
    +[$sample] = $array;
+
+Rule sets
+---------
+
+The rule is part of the following rule sets:
+
+@PHP71Migration
+  Using the `@PHP71Migration <./../../ruleSets/PHP71Migration.rst>`_ rule set will enable the ``list_syntax`` rule with the config below:
+
+  ``['syntax' => 'short']``
+
+@PHP73Migration
+  Using the `@PHP73Migration <./../../ruleSets/PHP73Migration.rst>`_ rule set will enable the ``list_syntax`` rule with the config below:
+
+  ``['syntax' => 'short']``
+
+@PHP74Migration
+  Using the `@PHP74Migration <./../../ruleSets/PHP74Migration.rst>`_ rule set will enable the ``list_syntax`` rule with the config below:
+
+  ``['syntax' => 'short']``
+
+@PHP80Migration
+  Using the `@PHP80Migration <./../../ruleSets/PHP80Migration.rst>`_ rule set will enable the ``list_syntax`` rule with the config below:
+
+  ``['syntax' => 'short']``

+ 33 - 0
src/RuleSet/Sets/PHP54MigrationSet.php

@@ -0,0 +1,33 @@
+<?php
+
+/*
+ * This file is part of PHP CS Fixer.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *     Dariusz Rumiński <dariusz.ruminski@gmail.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace PhpCsFixer\RuleSet\Sets;
+
+use PhpCsFixer\RuleSet\AbstractRuleSetDescription;
+
+/**
+ * @internal
+ */
+final class PHP54MigrationSet extends AbstractRuleSetDescription
+{
+    public function getRules()
+    {
+        return [
+            'array_syntax' => ['syntax' => 'short'],
+        ];
+    }
+
+    public function getDescription()
+    {
+        return 'Rules to improve code for PHP 5.6 compatibility.';
+    }
+}

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

@@ -22,6 +22,7 @@ final class PHP56MigrationSet extends AbstractRuleSetDescription
     public function getRules()
     public function getRules()
     {
     {
         return [
         return [
+            '@PHP54Migration' => true,
         ];
         ];
     }
     }
 
 

Some files were not shown because too many files changed in this diff