---
title: "lint/control-flow"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

if, switch, match, loops, return and the other control structures. Also in [format](/docs/rules/format/control-flow) (13) and [analyse](/docs/rules/analyse/control-flow) (8).

**[no-assign-in-condition](/docs/rules/lint/control-flow/no-assign-in-condition)**

Detects assignments in conditions which can lead to unexpected behavior and make the code harder

In the `code-quality` set. Report only. Intent: correctness.

**[no-else-after-return](/docs/rules/lint/control-flow/no-else-after-return)**

Drop the else after a branch that always returns, throws or exits, and move its body after the if.

In the `code-quality` set. Safe fix.

**[no-empty-catch](/docs/rules/lint/control-flow/no-empty-catch)**

Report an empty `catch` block, which swallows the exception.

In the `code-quality` set. Report only. Intent: correctness.

**[no-for-init-overwrite](/docs/rules/lint/control-flow/no-for-init-overwrite)**

Disallows a `for` loop's init expression overwriting a variable that is already defined.

In the `code-quality` set. Report only. Intent: suspicious. Upstream gates: `strictRules.overwriteVariablesWithLoop`.

**[no-loop-variable-overwrite](/docs/rules/lint/control-flow/no-loop-variable-overwrite)**

Disallows a `foreach` key or value variable overwriting a variable that is already defined.

In the `code-quality` set. Report only. Intent: suspicious. Upstream gates: `strictRules.overwriteVariablesWithLoop`.

**[no-return-assignment](/docs/rules/lint/control-flow/no-return-assignment)**

Local, dynamic and directly referenced variables should not be assigned and directly returned by a function or method.

In the `dead-code` set. Safe fix.

**[no-superfluous-elseif](/docs/rules/lint/control-flow/no-superfluous-elseif)**

Replaces superfluous `elseif` with `if`.

In the `dead-code` set. Safe fix.

**[no-switch-continue](/docs/rules/lint/control-flow/no-switch-continue)**

Switch case must not be ended with `continue` but with `break`.

In the `modernize` set. Safe fix.

**[no-unsafe-finally](/docs/rules/lint/control-flow/no-unsafe-finally)**

Detects control flow statements in `finally` blocks.

In the `code-quality` set. Report only. Intent: suspicious.

**[no-useless-else](/docs/rules/lint/control-flow/no-useless-else)**

There should not be useless `else` cases.

In the `early-return` set. Safe fix.

**[no-useless-return](/docs/rules/lint/control-flow/no-useless-return)**

There should not be an empty `return` statement at the end of a function.

In the `dead-code` set. Safe fix.

**[prefer-bare-return](/docs/rules/lint/control-flow/prefer-bare-return)**

A return statement wishing to return `void` should not return `null`.

Not in any set. Safe fix.

**[prefer-bool-return](/docs/rules/lint/control-flow/prefer-bool-return)**

Simplify `if` control structures that return the boolean result of their condition.

In the `code-quality` set. Safe fix.

**[prefer-combined-isset](/docs/rules/lint/control-flow/prefer-combined-isset)**

Using `isset($var) &&` multiple times should be done in one call.

In the `code-quality` set. Safe fix.

**[prefer-combined-unset](/docs/rules/lint/control-flow/prefer-combined-unset)**

Calling `unset` on multiple items should be done in one call.

In the `code-quality` set. Safe fix.

**[prefer-yield-from](/docs/rules/lint/control-flow/prefer-yield-from)**

If the function explicitly returns an array, and has the return type `iterable`, then `yield from` must be used instead of `return`.

In the `code-quality` set. Safe fix.
