no_trailing_comma_in_singleline.rst 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ========================================
  2. Rule ``no_trailing_comma_in_singleline``
  3. ========================================
  4. If a list of values separated by a comma is contained on a single line, then the
  5. last item MUST NOT have a trailing comma.
  6. Configuration
  7. -------------
  8. ``elements``
  9. ~~~~~~~~~~~~
  10. Which elements to fix.
  11. Allowed values: a subset of ``['arguments', 'array', 'array_destructuring', 'group_import']``
  12. Default value: ``['arguments', 'array_destructuring', 'array', 'group_import']``
  13. Examples
  14. --------
  15. Example #1
  16. ~~~~~~~~~~
  17. *Default* configuration.
  18. .. code-block:: diff
  19. --- Original
  20. +++ New
  21. <?php
  22. -foo($a,);
  23. -$foo = array(1,);
  24. -[$foo, $bar,] = $array;
  25. -use a\{ClassA, ClassB,};
  26. +foo($a);
  27. +$foo = array(1);
  28. +[$foo, $bar] = $array;
  29. +use a\{ClassA, ClassB};
  30. Example #2
  31. ~~~~~~~~~~
  32. With configuration: ``['elements' => ['array_destructuring']]``.
  33. .. code-block:: diff
  34. --- Original
  35. +++ New
  36. <?php
  37. foo($a,);
  38. -[$foo, $bar,] = $array;
  39. +[$foo, $bar] = $array;
  40. Rule sets
  41. ---------
  42. The rule is part of the following rule sets:
  43. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  44. - `@Symfony <./../../ruleSets/Symfony.rst>`_