Ir al contenido

Loose equality comparison (ARCH7195)

Esta página aún no está disponible en tu idioma.

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.