1.2.204. Comparisons Orientation

Maths has two comparisons styles : > or <. Both may include equality : <= and >=.

The analyzed code has less than 10% of one of them : for consistency reasons, it is recommended to make them all the same.

It is recommended to always use the same comparison style.

<?php

// Always compare in the same direction
if ($a > $c) {

} elseif ($c > $b) {

} else {
    // equality case
}

// Alterning comparison style lead to harder to read code
if ($b > 3) {

} elseif ($b < 3) {

}

?>

See also Comparison Operators.

1.2.204.1. Specs

Short name

Structures/GtOrLtFavorite

Rulesets

All, Changed Behavior, Preferences

Exakat since

1.3.2

PHP Version

All

Severity

Time To Fix

Precision

High

Features

comparison

Available in

Entreprise Edition, Exakat Cloud