increment_style.rst 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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'`` and ``'pre'``
  11. Default value: ``'pre'``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. <?php
  21. -$a++;
  22. -$b--;
  23. +++$a;
  24. +--$b;
  25. Example #2
  26. ~~~~~~~~~~
  27. With configuration: ``['style' => 'post']``.
  28. .. code-block:: diff
  29. --- Original
  30. +++ New
  31. <?php
  32. -++$a;
  33. ---$b;
  34. +$a++;
  35. +$b--;
  36. Rule sets
  37. ---------
  38. The rule is part of the following rule sets:
  39. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  40. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  41. References
  42. ----------
  43. - Fixer class: `PhpCsFixer\\Fixer\\Operator\\IncrementStyleFixer <./../../../src/Fixer/Operator/IncrementStyleFixer.php>`_
  44. - Test class: `PhpCsFixer\\Tests\\Fixer\\Operator\\IncrementStyleFixerTest <./../../../tests/Fixer/Operator/IncrementStyleFixerTest.php>`_
  45. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.