array_syntax.rst 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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'`` and ``'short'``
  11. Default value: ``'short'``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. <?php
  21. -array(1,2);
  22. +[1,2];
  23. Example #2
  24. ~~~~~~~~~~
  25. With configuration: ``['syntax' => 'long']``.
  26. .. code-block:: diff
  27. --- Original
  28. +++ New
  29. <?php
  30. -[1,2];
  31. +array(1,2);
  32. Rule sets
  33. ---------
  34. The rule is part of the following rule sets:
  35. - `@PER <./../../ruleSets/PER.rst>`_
  36. - `@PER-CS <./../../ruleSets/PER-CS.rst>`_
  37. - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
  38. - `@PHP54Migration <./../../ruleSets/PHP54Migration.rst>`_
  39. - `@PHP70Migration <./../../ruleSets/PHP70Migration.rst>`_
  40. - `@PHP71Migration <./../../ruleSets/PHP71Migration.rst>`_
  41. - `@PHP73Migration <./../../ruleSets/PHP73Migration.rst>`_
  42. - `@PHP74Migration <./../../ruleSets/PHP74Migration.rst>`_
  43. - `@PHP80Migration <./../../ruleSets/PHP80Migration.rst>`_
  44. - `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
  45. - `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
  46. - `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
  47. - `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_
  48. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  49. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  50. References
  51. ----------
  52. - Fixer class: `PhpCsFixer\\Fixer\\ArrayNotation\\ArraySyntaxFixer <./../../../src/Fixer/ArrayNotation/ArraySyntaxFixer.php>`_
  53. - Test class: `PhpCsFixer\\Tests\\Fixer\\ArrayNotation\\ArraySyntaxFixerTest <./../../../tests/Fixer/ArrayNotation/ArraySyntaxFixerTest.php>`_
  54. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.