operator_linebreak.rst 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. ===========================
  2. Rule ``operator_linebreak``
  3. ===========================
  4. Operators - when multiline - must always be at the beginning or at the end of
  5. the line.
  6. Configuration
  7. -------------
  8. ``only_booleans``
  9. ~~~~~~~~~~~~~~~~~
  10. Whether to limit operators to only boolean ones.
  11. Allowed types: ``bool``
  12. Default value: ``false``
  13. ``position``
  14. ~~~~~~~~~~~~
  15. Whether to place operators at the beginning or at the end of the line.
  16. Allowed values: ``'beginning'`` and ``'end'``
  17. Default value: ``'beginning'``
  18. Examples
  19. --------
  20. Example #1
  21. ~~~~~~~~~~
  22. *Default* configuration.
  23. .. code-block:: diff
  24. --- Original
  25. +++ New
  26. <?php
  27. function foo() {
  28. - return $bar ||
  29. - $baz;
  30. + return $bar
  31. + || $baz;
  32. }
  33. Example #2
  34. ~~~~~~~~~~
  35. With configuration: ``['position' => 'end']``.
  36. .. code-block:: diff
  37. --- Original
  38. +++ New
  39. <?php
  40. function foo() {
  41. - return $bar
  42. - || $baz;
  43. + return $bar ||
  44. + $baz;
  45. }
  46. Rule sets
  47. ---------
  48. The rule is part of the following rule sets:
  49. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ with config:
  50. ``['only_booleans' => true]``
  51. - `@Symfony <./../../ruleSets/Symfony.rst>`_ with config:
  52. ``['only_booleans' => true]``
  53. References
  54. ----------
  55. - Fixer class: `PhpCsFixer\\Fixer\\Operator\\OperatorLinebreakFixer <./../../../src/Fixer/Operator/OperatorLinebreakFixer.php>`_
  56. - Test class: `PhpCsFixer\\Tests\\Fixer\\Operator\\OperatorLinebreakFixerTest <./../../../tests/Fixer/Operator/OperatorLinebreakFixerTest.php>`_
  57. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.