php-src/Zend/tests/numeric_strings/neg_num_string.phpt
George Peter Banyard b2248789ed Implement 'Saner Numeric Strings' RFC:
RFC: https://wiki.php.net/rfc/saner-numeric-strings

This removes the -1 allow_error mode from is_numeric_string functions and replaces it by
a trailing boolean out argument to preserve BC in a couple of places.

Most of the changes can be resumed to "numeric" strings which emitted a E_NOTICE now emit
a E_WARNING and "numeric" strings which emitted a E_WARNING now throw a TypeError.

This mostly affects:
 - String offsets
 - Arithmetic operations
 - Bitwise operations

Closes GH-5762
2020-07-29 02:51:09 +01:00

48 lines
825 B
PHP

--TEST--
Test edge-cases for negative num strings in interpolated string offsets
--FILE--
<?php
$a = [
"0" => 1,
"-0" => 2,
"1" => 3,
"-1" => 4,
"0x0" => 5,
"-0x0" => 6,
"00" => 7,
"-00" => 8,
"9223372036854775808" => 9,
"-9223372036854775808" => 10,
"2147483648" => 11,
"-2147483648" => 12,
];
var_dump("$a[0]");
var_dump("$a[-0]");
var_dump("$a[1]");
var_dump("$a[-1]");
var_dump("$a[0x0]");
var_dump("$a[-0x0]");
var_dump("$a[00]");
var_dump("$a[-00]");
var_dump("$a[9223372036854775808]");
var_dump("$a[-9223372036854775808]");
var_dump("$a[2147483648]");
var_dump("$a[-2147483648]");
?>
--EXPECT--
string(1) "1"
string(1) "2"
string(1) "3"
string(1) "4"
string(1) "5"
string(1) "6"
string(1) "7"
string(1) "8"
string(1) "9"
string(2) "10"
string(2) "11"
string(2) "12"