1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-05 13:47:33 +02:00

DibiTranslator: deprecated support for hex number in strings '0xFF' (BC break)

related to PHP7 and https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings
This commit is contained in:
David Grudl
2015-06-15 14:08:03 +02:00
parent 66afffcddc
commit d3151f7c65
2 changed files with 4 additions and 7 deletions

View File

@@ -361,8 +361,11 @@ final class DibiTranslator extends DibiObject
return 'NULL'; return 'NULL';
} elseif (is_string($value) && preg_match('#[+-]?\d++(?:e\d+)?\z#A', $value)) { } elseif (is_string($value) && preg_match('#[+-]?\d++(?:e\d+)?\z#A', $value)) {
return $value; // support for long numbers - keep them unchanged return $value; // support for long numbers - keep them unchanged
} elseif (is_string($value) && substr($value, 1, 1) === 'x' && is_numeric($value)) {
trigger_error('Support for hex strings has been deprecated.', E_USER_DEPRECATED);
return (string) hexdec($value);
} else { } else {
return (string) (int) ($value + 0); return (string) (int) $value;
} }
case 'f': // float case 'f': // float

View File

@@ -73,12 +73,6 @@ Assert::same(
$conn->translate("SELECT %f", '-.12345678912345678912345678e10') $conn->translate("SELECT %f", '-.12345678912345678912345678e10')
); );
// hex numbers
Assert::same(
reformat('SELECT 17'),
$conn->translate("SELECT %i", '0x11')
);
// invalid input // invalid input
$e = Assert::exception(function() use ($conn) { $e = Assert::exception(function() use ($conn) {
$conn->translate("SELECT %s", (object) array(123), ', %m', 123); $conn->translate("SELECT %s", (object) array(123), ', %m', 123);