Pattern: Missing use of early exit
Issue: -
Requires use of early exit.
Rule provides the following settings:
ignoreStandaloneIfInScope
: ignoresif
that is standalone in scope, like this:
foreach ($values as $value) {
if ($value) {
doSomething();
}
}
ignoreOneLineTrailingIf
: ignoresif
that has one line content and is on the last position in scope, like this:
foreach ($values as $value) {
$value .= 'whatever';
if ($value) {
doSomething();
}
}
ignoreTrailingIfWithOneInstruction
: ignoresif
that has only one instruction and is on the last position in scope, like this:
foreach ($values as $value) {
$value .= 'whatever';
if ($value) {
doSomething(function () {
// Anything
});
}
}