control_structure_continuation_position.rst 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ================================================
  2. Rule ``control_structure_continuation_position``
  3. ================================================
  4. Control structure continuation keyword must be on the configured line.
  5. Configuration
  6. -------------
  7. ``position``
  8. ~~~~~~~~~~~~
  9. The position of the keyword that continues the control structure.
  10. Allowed values: ``'next_line'`` and ``'same_line'``
  11. Default value: ``'same_line'``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. <?php
  21. if ($baz == true) {
  22. echo "foo";
  23. -}
  24. -else {
  25. +} else {
  26. echo "bar";
  27. }
  28. Example #2
  29. ~~~~~~~~~~
  30. With configuration: ``['position' => 'next_line']``.
  31. .. code-block:: diff
  32. --- Original
  33. +++ New
  34. <?php
  35. if ($baz == true) {
  36. echo "foo";
  37. -} else {
  38. +}
  39. +else {
  40. echo "bar";
  41. }
  42. Rule sets
  43. ---------
  44. The rule is part of the following rule sets:
  45. - `@PER <./../../ruleSets/PER.rst>`_
  46. - `@PER-CS <./../../ruleSets/PER-CS.rst>`_
  47. - `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_
  48. - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
  49. - `@PSR2 <./../../ruleSets/PSR2.rst>`_
  50. - `@PSR12 <./../../ruleSets/PSR12.rst>`_
  51. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  52. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  53. References
  54. ----------
  55. - Fixer class: `PhpCsFixer\\Fixer\\ControlStructure\\ControlStructureContinuationPositionFixer <./../../../src/Fixer/ControlStructure/ControlStructureContinuationPositionFixer.php>`_
  56. - Test class: `PhpCsFixer\\Tests\\Fixer\\ControlStructure\\ControlStructureContinuationPositionFixerTest <./../../../tests/Fixer/ControlStructure/ControlStructureContinuationPositionFixerTest.php>`_
  57. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.