heredoc_closing_marker.rst 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ===============================
  2. Rule ``heredoc_closing_marker``
  3. ===============================
  4. Unify ``heredoc`` or ``nowdoc`` closing marker.
  5. Configuration
  6. -------------
  7. ``closing_marker``
  8. ~~~~~~~~~~~~~~~~~~
  9. Preferred closing marker.
  10. Allowed types: ``string``
  11. Default value: ``'EOD'``
  12. ``explicit_heredoc_style``
  13. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  14. Whether the closing marker should be wrapped in double quotes.
  15. Allowed types: ``bool``
  16. Default value: ``false``
  17. ``reserved_closing_markers``
  18. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  19. Reserved closing markers to be kept unchanged.
  20. Allowed types: ``list<string>``
  21. Default value: ``['CSS', 'DIFF', 'HTML', 'JS', 'JSON', 'MD', 'PHP', 'PYTHON', 'RST', 'TS', 'SQL', 'XML', 'YAML']``
  22. Examples
  23. --------
  24. Example #1
  25. ~~~~~~~~~~
  26. *Default* configuration.
  27. .. code-block:: diff
  28. --- Original
  29. +++ New
  30. -<?php $a = <<<"TEST"
  31. +<?php $a = <<<EOD
  32. Foo
  33. -TEST;
  34. +EOD;
  35. Example #2
  36. ~~~~~~~~~~
  37. With configuration: ``['closing_marker' => 'EOF']``.
  38. .. code-block:: diff
  39. --- Original
  40. +++ New
  41. -<?php $a = <<<'TEST'
  42. +<?php $a = <<<'EOF'
  43. Foo
  44. -TEST;
  45. +EOF;
  46. Example #3
  47. ~~~~~~~~~~
  48. With configuration: ``['explicit_heredoc_style' => true]``.
  49. .. code-block:: diff
  50. --- Original
  51. +++ New
  52. -<?php $a = <<<EOD
  53. +<?php $a = <<<"EOD"
  54. Foo
  55. EOD;
  56. References
  57. ----------
  58. - Fixer class: `PhpCsFixer\\Fixer\\StringNotation\\HeredocClosingMarkerFixer <./../../../src/Fixer/StringNotation/HeredocClosingMarkerFixer.php>`_
  59. - Test class: `PhpCsFixer\\Tests\\Fixer\\StringNotation\\HeredocClosingMarkerFixerTest <./../../../tests/Fixer/StringNotation/HeredocClosingMarkerFixerTest.php>`_
  60. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.