array_syntax.rst 994 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. @Symfony
  38. Using the ``@Symfony`` rule set will enable the ``array_syntax`` rule with the config below:
  39. ``['syntax' => 'short']``
  40. @PhpCsFixer
  41. Using the ``@PhpCsFixer`` rule set will enable the ``array_syntax`` rule with the config below:
  42. ``['syntax' => 'short']``