1.2.533. Identical Conditions

These logical expressions contain members that are identical.

This means those expressions may be simplified.

<?php

// twice $a
if ($a || $b || $c || $a) {  }

// Hiding in parenthesis is bad
if (($a) ^ ($a)) {}

// expressions may be large
if ($a === 1 && 1 === $a) {}

?>

1.2.533.1. Suggestions

  • Merge the two structures into one unique test

  • Add extra expressions between the two structures

  • Nest the structures, to show that different attempts are made

1.2.533.2. Specs

Short name

Structures/IdenticalConditions

Rulesets

All, Analyze, CE, CI-checks

Exakat since

0.8.4

PHP Version

All

Severity

Critical

Time To Fix

Quick (30 mins)

Precision

High

Examples

WordPress, Dolibarr

Available in

Entreprise Edition, Community Edition, Exakat Cloud