heredoc_indentation.rst 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ============================
  2. Rule ``heredoc_indentation``
  3. ============================
  4. Heredoc/nowdoc content must be properly indented.
  5. Configuration
  6. -------------
  7. ``indentation``
  8. ~~~~~~~~~~~~~~~
  9. Whether the indentation should be the same as in the start token line or one
  10. level more.
  11. Allowed values: ``'same_as_start'`` and ``'start_plus_one'``
  12. Default value: ``'start_plus_one'``
  13. Examples
  14. --------
  15. Example #1
  16. ~~~~~~~~~~
  17. *Default* configuration.
  18. .. code-block:: diff
  19. --- Original
  20. +++ New
  21. <?php
  22. $heredoc = <<<EOD
  23. -abc
  24. - def
  25. -EOD;
  26. + abc
  27. + def
  28. + EOD;
  29. $nowdoc = <<<'EOD'
  30. -abc
  31. - def
  32. -EOD;
  33. + abc
  34. + def
  35. + EOD;
  36. Example #2
  37. ~~~~~~~~~~
  38. With configuration: ``['indentation' => 'same_as_start']``.
  39. .. code-block:: diff
  40. --- Original
  41. +++ New
  42. <?php
  43. $nowdoc = <<<'EOD'
  44. -abc
  45. - def
  46. -EOD;
  47. + abc
  48. + def
  49. + EOD;
  50. Rule sets
  51. ---------
  52. The rule is part of the following rule sets:
  53. - `@PHP73Migration <./../../ruleSets/PHP73Migration.rst>`_
  54. - `@PHP74Migration <./../../ruleSets/PHP74Migration.rst>`_
  55. - `@PHP80Migration <./../../ruleSets/PHP80Migration.rst>`_
  56. - `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
  57. - `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_