1.2.1454. Wrong Range Check

The interval check should use && and not ||.

<?php

//interval correctly checked a is between 2 and 999
if ($a > 1 && $a < 1000) {}

//interval incorrectly checked : a is 2 or more ($a < 1000 is never checked)
if ($a > 1 || $a < 1000) {}

?>

1.2.1454.1. Suggestions

  • Make the interval easy to read and understand

  • Check the truth table for the logical operation

1.2.1454.2. Specs

Short name

Structures/WrongRange

Rulesets

All, Analyze, Changed Behavior

Exakat since

1.2.5

PHP Version

All

Severity

Major

Time To Fix

Instant (5 mins)

Precision

Very high

Examples

Dolibarr, WordPress

Available in

Entreprise Edition, Exakat Cloud