Description:
------------
It is well known that PHP casts numeric string indexes to integers, and it is normally impossible to force such indexes to remain strings. For example, the script below will output "integer":
$test = array("123" => 1);
echo gettype(key($test)); // integer
However, it is possible to achieve this if we assign numeric string property to an object (by using the ->{} syntax), and then cast it to array. Not only will the index retain it's string type, but it will also be impossible to access that index with [], which can't be correct behaviour. See attached example.
Test script:
---------------
<?php
$test = new stdClass();
$test->{"123"} = 1;
$test = (array)$test;
$key = key($test);
echo gettype($key);
echo "\n";
echo $test[$key];
?>
Expected result:
----------------
integer
1
Actual result:
--------------
string
PHP Notice: Undefined index: 123 in test.php on line 9