EnumIsValidRule : fix int casting

This commit is contained in:
Jérémy Munsch 2021-09-11 22:45:27 +02:00
parent b3f54a65c5
commit 5e3f825dca
No known key found for this signature in database
GPG key ID: 677E1F9F80C16560

View file

@ -22,7 +22,8 @@ class EnumIsValidRule extends BaseEnumRule
{
try {
// try cast to int if is int
$value = is_numeric($value) && floatval(intval($value)) === floatval($value) ? (int)$value : $value;
$value = (is_numeric($value) and floatval(intval($value)) === floatval($value)) ?
(int)$value : $value;
forward_static_call([$this->enumClass, 'make'], $value);
} catch (TypeError $e) {
$this->messageType = 1;