Skip to content

MIR0408

ImpossibleIdenticalComparison

An identical comparison (===) between values of incompatible types that can never be true. This indicates dead code or a logic error.

<?php
function checkType($value): bool {
if ($value === 'string' && $value === 123) {
// This can never be true - a value cannot be both string and int
return true;
}
return false;
}

Review the comparison logic and remove impossible conditions:

<?php
function checkType($value): bool {
// Check for string OR int instead
if ($value === 'string' || $value === 123) {
return true;
}
return false;
}