increment_style.rst 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ========================
  2. Rule ``increment_style``
  3. ========================
  4. Pre- or post-increment and decrement operators should be used if possible.
  5. Configuration
  6. -------------
  7. ``style``
  8. ~~~~~~~~~
  9. Whether to use pre- or post-increment and decrement operators.
  10. Allowed values: ``'post'``, ``'pre'``
  11. Default value: ``'pre'``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. @@ -1,3 +1,3 @@
  21. <?php
  22. -$a++;
  23. -$b--;
  24. +++$a;
  25. +--$b;
  26. Example #2
  27. ~~~~~~~~~~
  28. With configuration: ``['style' => 'post']``.
  29. .. code-block:: diff
  30. --- Original
  31. +++ New
  32. @@ -1,3 +1,3 @@
  33. <?php
  34. -++$a;
  35. ---$b;
  36. +$a++;
  37. +$b--;
  38. Rule sets
  39. ---------
  40. The rule is part of the following rule sets:
  41. @PhpCsFixer
  42. Using the `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ rule set will enable the ``increment_style`` rule with the default config.
  43. @Symfony
  44. Using the `@Symfony <./../../ruleSets/Symfony.rst>`_ rule set will enable the ``increment_style`` rule with the default config.