Aller au contenu

Loose equality comparison (ARCH7195)

Ce contenu n’est pas encore disponible dans votre langue.

Key php.quality.loose-equality · Severity info · Category quality

In PHP the == operator coerces operands (0 == "abc" could be true in older versions), causing subtle bugs. Use the type-safe ===.

<?php
function isZero($value): bool
{
return $value == 0;
}
<?php
function isZero(int $value): bool
{
return $value === 0;
}

Always use the strict === and !== operators to avoid type coercion.