array_syntax.rst 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. =====================
  2. Rule ``array_syntax``
  3. =====================
  4. PHP arrays should be declared using the configured syntax.
  5. Configuration
  6. -------------
  7. ``syntax``
  8. ~~~~~~~~~~
  9. Whether to use the ``long`` or ``short`` array syntax.
  10. Allowed values: ``'long'``, ``'short'``
  11. Default value: ``'long'``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. @@ -1,2 +1,2 @@
  21. <?php
  22. -[1,2];
  23. +array(1,2);
  24. Example #2
  25. ~~~~~~~~~~
  26. With configuration: ``['syntax' => 'short']``.
  27. .. code-block:: diff
  28. --- Original
  29. +++ New
  30. @@ -1,2 +1,2 @@
  31. <?php
  32. -array(1,2);
  33. +[1,2];
  34. Rule sets
  35. ---------
  36. The rule is part of the following rule sets:
  37. @PHP54Migration
  38. Using the `@PHP54Migration <./../../ruleSets/PHP54Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
  39. ``['syntax' => 'short']``
  40. @PHP56Migration
  41. Using the `@PHP56Migration <./../../ruleSets/PHP56Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
  42. ``['syntax' => 'short']``
  43. @PHP70Migration
  44. Using the `@PHP70Migration <./../../ruleSets/PHP70Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
  45. ``['syntax' => 'short']``
  46. @PHP71Migration
  47. Using the `@PHP71Migration <./../../ruleSets/PHP71Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
  48. ``['syntax' => 'short']``
  49. @PHP73Migration
  50. Using the `@PHP73Migration <./../../ruleSets/PHP73Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
  51. ``['syntax' => 'short']``
  52. @PHP74Migration
  53. Using the `@PHP74Migration <./../../ruleSets/PHP74Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
  54. ``['syntax' => 'short']``
  55. @PHP80Migration
  56. Using the `@PHP80Migration <./../../ruleSets/PHP80Migration.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
  57. ``['syntax' => 'short']``
  58. @PhpCsFixer
  59. Using the `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
  60. ``['syntax' => 'short']``
  61. @Symfony
  62. Using the `@Symfony <./../../ruleSets/Symfony.rst>`_ rule set will enable the ``array_syntax`` rule with the config below:
  63. ``['syntax' => 'short']``