Minor tweaking

This commit is contained in:
Pavel Shevaev 2022-12-06 14:31:27 +03:00
parent dd6b1e172e
commit 57d1308609
1 changed files with 8 additions and 10 deletions

View File

@ -13,7 +13,6 @@ function array_extract_val(&$arr, $assoc, $name, $default = null)
{
if($default !== null)
return $default;
throw new Exception("$name: No next array item");
}
return array_shift($arr);
@ -23,7 +22,6 @@ function array_extract_val(&$arr, $assoc, $name, $default = null)
{
if($default !== null)
return $default;
throw new Exception("$name: No array item");
}
@ -78,7 +76,7 @@ function val_uint64($val)
throw new Exception("Bad item, not a number(" . serialize($val) . ")");
$val = 1*$val;
if(is_float($val))
throw new Exception("Incompatible type, expected uint64, float given: $val");
throw new Exception("Incompatible type, expected uint64, float given: $val");
return $val;
}
@ -88,7 +86,7 @@ function val_int64($val)
throw new Exception("Bad item, not a number(" . serialize($val) . ")");
$val = 1*$val;
if(is_float($val))
throw new Exception("Incompatible type, expected int64, float given: $val");
throw new Exception("Incompatible type, expected int64, float given: $val");
return $val;
}
@ -98,7 +96,7 @@ function val_uint32($val)
throw new Exception("Bad item, not a number(" . serialize($val) . ")");
$val = 1*$val;
if(is_float($val))
throw new Exception("Incompatible type, expected uint32, float given: $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;
@ -110,7 +108,7 @@ function val_int32($val)
throw new Exception("Bad item, not a number(" . serialize($val) . ")");
$val = 1*$val;
if(is_float($val))
throw new Exception("Incompatible type, expected int32, float given: $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;
@ -122,7 +120,7 @@ function val_uint16($val)
throw new Exception("Bad item, not a number(" . serialize($val) . ")");
$val = 1*$val;
if(is_float($val))
throw new Exception("Incompatible type, expected uint16, float given: $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;
@ -134,7 +132,7 @@ function val_int16($val)
throw new Exception("Bad item, not a number(" . serialize($val) . ")");
$val = 1*$val;
if(is_float($val))
throw new Exception("Incompatible type, expected int16, float given: $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;
@ -146,7 +144,7 @@ function val_uint8($val)
throw new Exception("Bad item, not a number(" . serialize($val) . ")");
$val = 1*$val;
if(is_float($val))
throw new Exception("Incompatible type, expected uint8, float given: $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;
@ -158,7 +156,7 @@ function val_int8($val)
throw new Exception("Bad item, not a number(" . serialize($val) . ")");
$val = 1*$val;
if(is_float($val))
throw new Exception("Incompatible type, expected int8, float given: $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;