Skip to content

Files

Latest commit

 

History

History
29 lines (19 loc) · 526 Bytes

Generic.CodeAnalysis.UnconditionalIfStatement.md

File metadata and controls

29 lines (19 loc) · 526 Bytes

Pattern: Constant if statement

Issue: -

Description

If statements that are always evaluated should be simplified or avoided altogether.

Example

Example of incorrect code:

if (true) {
    $var = 1;
}

Example of correct code:

if ($test) {
    $var = 1;
}

Further Reading