From 558d4b65f27b4df6d13030ec46f3b8be14c71ba3 Mon Sep 17 00:00:00 2001 From: madpwnhammer Date: Mon, 12 Sep 2022 17:16:06 +0300 Subject: [PATCH] Fixed float checks error messages --- targets/php/php.inc.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/targets/php/php.inc.php b/targets/php/php.inc.php index e2d744e..bff8fde 100644 --- a/targets/php/php.inc.php +++ b/targets/php/php.inc.php @@ -548,18 +548,13 @@ function mtg_php_val_double($val) return 1*$val; } -function mtg_php_check_float($val) -{ - if(is_float($val)) - throw new Exception("Incompatible type, expected uint64, float given: $val"); -} - function mtg_php_val_uint64($val) { if(!is_numeric($val)) throw new Exception("Bad item, not a number(" . serialize($val) . ")"); $val = 1*$val; - mtg_php_check_float($val); + if(is_float($val)) + throw new Exception("Incompatible type, expected uint64, float given: $val"); return $val; } @@ -568,7 +563,8 @@ function mtg_php_val_int64($val) if(!is_numeric($val)) throw new Exception("Bad item, not a number(" . serialize($val) . ")"); $val = 1*$val; - mtg_php_check_float($val); + if(is_float($val)) + throw new Exception("Incompatible type, expected int64, float given: $val"); return $val; } @@ -577,7 +573,8 @@ function mtg_php_val_uint32($val) if(!is_numeric($val)) throw new Exception("Bad item, not a number(" . serialize($val) . ")"); $val = 1*$val; - mtg_php_check_float($val); + if(is_float($val)) + throw new Exception("Incompatible type, expected uint32, float given: $val"); if(($val < 0 && $val < -2147483648) || ($val > 0 && $val > 0xFFFFFFFF)) throw new Exception("Value not in range: $val"); return $val; @@ -588,7 +585,8 @@ function mtg_php_val_int32($val) if(!is_numeric($val)) throw new Exception("Bad item, not a number(" . serialize($val) . ")"); $val = 1*$val; - mtg_php_check_float($val); + if(is_float($val)) + throw new Exception("Incompatible type, expected int32, float given: $val"); if($val > 2147483647 || $val < -2147483648) throw new Exception("Value not in range: $val"); return $val; @@ -599,7 +597,8 @@ function mtg_php_val_uint16($val) if(!is_numeric($val)) throw new Exception("Bad item, not a number(" . serialize($val) . ")"); $val = 1*$val; - mtg_php_check_float($val); + if(is_float($val)) + throw new Exception("Incompatible type, expected uint16, float given: $val"); if($val > 0xFFFF || $val < 0) throw new Exception("Value not in range: $val"); return $val; @@ -610,7 +609,8 @@ function mtg_php_val_int16($val) if(!is_numeric($val)) throw new Exception("Bad item, not a number(" . serialize($val) . ")"); $val = 1*$val; - mtg_php_check_float($val); + if(is_float($val)) + throw new Exception("Incompatible type, expected int16, float given: $val"); if($val > 32767 || $val < -32768) throw new Exception("Value not in range: $val"); return $val; @@ -621,7 +621,8 @@ function mtg_php_val_uint8($val) if(!is_numeric($val)) throw new Exception("Bad item, not a number(" . serialize($val) . ")"); $val = 1*$val; - mtg_php_check_float($val); + if(is_float($val)) + throw new Exception("Incompatible type, expected uint8, float given: $val"); if($val > 0xFF || $val < 0) throw new Exception("Value not in range: $val"); return $val; @@ -632,7 +633,8 @@ function mtg_php_val_int8($val) if(!is_numeric($val)) throw new Exception("Bad item, not a number(" . serialize($val) . ")"); $val = 1*$val; - mtg_php_check_float($val); + if(is_float($val)) + throw new Exception("Incompatible type, expected int8, float given: $val"); if($val > 127 || $val < -128) throw new Exception("Value not in range: $val"); return $val;