1.2.203. Comparison On Different Types

This rule reports comparisons and spaceship operator that are used with distinct types. When the types are distinct, PHP apply silent type juggling, and it may result in unexpected results.

<?php

1 == 'a';

?>

1.2.203.1. Suggestions

  • Ensure both operands are using the same type.

1.2.203.2. Specs

Short name

Php/ComparisonOnDifferentTypes

Rulesets

All, Changed Behavior, Dump

Exakat since

2.5.3

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Medium

Available in

Entreprise Edition, Exakat Cloud