no_alternative_syntax.rst 962 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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>`_