whitespace_after_comma_in_array.rst 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ========================================
  2. Rule ``whitespace_after_comma_in_array``
  3. ========================================
  4. In array declaration, there MUST be a whitespace after each comma.
  5. Configuration
  6. -------------
  7. ``ensure_single_space``
  8. ~~~~~~~~~~~~~~~~~~~~~~~
  9. If there are only horizontal whitespaces after the comma then ensure it is a
  10. single space.
  11. Allowed types: ``bool``
  12. Default value: ``false``
  13. Examples
  14. --------
  15. Example #1
  16. ~~~~~~~~~~
  17. *Default* configuration.
  18. .. code-block:: diff
  19. --- Original
  20. +++ New
  21. <?php
  22. -$sample = array(1,'a',$b,);
  23. +$sample = array(1, 'a', $b, );
  24. Example #2
  25. ~~~~~~~~~~
  26. With configuration: ``['ensure_single_space' => true]``.
  27. .. code-block:: diff
  28. --- Original
  29. +++ New
  30. <?php
  31. -$sample = [1,2, 3, 4, 5];
  32. +$sample = [1, 2, 3, 4, 5];
  33. Rule sets
  34. ---------
  35. The rule is part of the following rule sets:
  36. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ with config:
  37. ``['ensure_single_space' => true]``
  38. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  39. References
  40. ----------
  41. - Fixer class: `PhpCsFixer\\Fixer\\ArrayNotation\\WhitespaceAfterCommaInArrayFixer <./../../../src/Fixer/ArrayNotation/WhitespaceAfterCommaInArrayFixer.php>`_
  42. - Test class: `PhpCsFixer\\Tests\\Fixer\\ArrayNotation\\WhitespaceAfterCommaInArrayFixerTest <./../../../tests/Fixer/ArrayNotation/WhitespaceAfterCommaInArrayFixerTest.php>`_
  43. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.