Issue Bug Rejected

#103177Inconsistent behavior in MathUtility::canBeInterpretedAsInteger() for boolean values

Mathias Brodala 02/22/24, 11:52 updated 10/23/25, 14:05

Description

The behavior of MathUtility::canBeInterpretedAsInteger() is inconsistent:

var_dump(MathUtility::canBeInterpretedAsInteger(true)); // true
var_dump(MathUtility::canBeInterpretedAsInteger(false)); // false

Assuming that the common true = 1, false = 0 logic applies, the behavior should be fixed to accept both boolean values. Both can be coerced into integers and thus interpreted a such:

var_dump(MathUtility::canBeInterpretedAsInteger(true)); // true
var_dump(MathUtility::canBeInterpretedAsInteger(false)); // true

Alternatively both boolean values should be rejected for consistency:

var_dump(MathUtility::canBeInterpretedAsInteger(true)); // false
var_dump(MathUtility::canBeInterpretedAsInteger(false)); // false

Reviews 1