no_alternative_syntax.rst 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ==============================
  2. Rule ``no_alternative_syntax``
  3. ==============================
  4. Replace control structure alternative syntax to use braces.
  5. Configuration
  6. -------------
  7. ``fix_non_monolithic_code``
  8. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. Whether to also fix code with inline HTML.
  10. Allowed types: ``bool``
  11. Default value: ``true``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. <?php
  21. -if(true):echo 't';else:echo 'f';endif;
  22. +if(true) { echo 't';} else { echo 'f';}
  23. Example #2
  24. ~~~~~~~~~~
  25. With configuration: ``['fix_non_monolithic_code' => true]``.
  26. .. code-block:: diff
  27. --- Original
  28. +++ New
  29. -<?php if ($condition): ?>
  30. +<?php if ($condition) { ?>
  31. Lorem ipsum.
  32. -<?php endif; ?>
  33. +<?php } ?>
  34. Rule sets
  35. ---------
  36. The rule is part of the following rule sets:
  37. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  38. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  39. References
  40. ----------
  41. - Fixer class: `PhpCsFixer\\Fixer\\ControlStructure\\NoAlternativeSyntaxFixer <./../../../src/Fixer/ControlStructure/NoAlternativeSyntaxFixer.php>`_
  42. - Test class: `PhpCsFixer\\Tests\\Fixer\\ControlStructure\\NoAlternativeSyntaxFixerTest <./../../../tests/Fixer/ControlStructure/NoAlternativeSyntaxFixerTest.php>`_
  43. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.