empty_loop_condition.rst 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. =============================
  2. Rule ``empty_loop_condition``
  3. =============================
  4. Empty loop-condition must be in configured style.
  5. Configuration
  6. -------------
  7. ``style``
  8. ~~~~~~~~~
  9. Style of empty loop-condition.
  10. Allowed values: ``'for'`` and ``'while'``
  11. Default value: ``'while'``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. <?php
  21. -for(;;) {
  22. +while (true) {
  23. foo();
  24. }
  25. -do {
  26. +while (true) {
  27. foo();
  28. -} while(true); // do while
  29. +} // do while
  30. Example #2
  31. ~~~~~~~~~~
  32. With configuration: ``['style' => 'for']``.
  33. .. code-block:: diff
  34. --- Original
  35. +++ New
  36. <?php
  37. -while(true) {
  38. +for(;;) {
  39. foo();
  40. }
  41. Rule sets
  42. ---------
  43. The rule is part of the following rule sets:
  44. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  45. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  46. References
  47. ----------
  48. - Fixer class: `PhpCsFixer\\Fixer\\ControlStructure\\EmptyLoopConditionFixer <./../../../src/Fixer/ControlStructure/EmptyLoopConditionFixer.php>`_
  49. - Test class: `PhpCsFixer\\Tests\\Fixer\\ControlStructure\\EmptyLoopConditionFixerTest <./../../../tests/Fixer/ControlStructure/EmptyLoopConditionFixerTest.php>`_
  50. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.