long_to_shorthand_operator.rst 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ===================================
  2. Rule ``long_to_shorthand_operator``
  3. ===================================
  4. Shorthand notation for operators should be used if possible.
  5. Warning
  6. -------
  7. Using this rule is risky
  8. ~~~~~~~~~~~~~~~~~~~~~~~~
  9. Risky when applying for string offsets (e.g. ``<?php $text = "foo"; $text[0] =
  10. $text[0] & "\x7F";``).
  11. Examples
  12. --------
  13. Example #1
  14. ~~~~~~~~~~
  15. .. code-block:: diff
  16. --- Original
  17. +++ New
  18. <?php
  19. -$i = $i + 10;
  20. +$i += 10;
  21. Rule sets
  22. ---------
  23. The rule is part of the following rule sets:
  24. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
  25. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_
  26. References
  27. ----------
  28. - Fixer class: `PhpCsFixer\\Fixer\\Operator\\LongToShorthandOperatorFixer <./../../../src/Fixer/Operator/LongToShorthandOperatorFixer.php>`_
  29. - Test class: `PhpCsFixer\\Tests\\Fixer\\Operator\\LongToShorthandOperatorFixerTest <./../../../tests/Fixer/Operator/LongToShorthandOperatorFixerTest.php>`_
  30. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.