empty_loop_condition.rst 916 B

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