php-src/Zend/tests/object_array_cast.phpt
Andrea Faulds a0502b89a6 Convert numeric keys in object/array casts
RFC: https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts

This converts key types as appropriate in object to array and array to object
casts, as well as in get_object_vars().
2016-11-14 18:20:45 +00:00

48 lines
524 B
PHP

--TEST--
(object) (array) and (array) (object) casts
--FILE--
<?php
$arr = [1, 2, 3];
var_dump((object) (array) $arr);
var_dump($arr);
$obj = (object) [1, 2, 3];
var_dump((array) (object) $obj);
var_dump($obj);
?>
--EXPECT--
object(stdClass)#1 (3) {
["0"]=>
int(1)
["1"]=>
int(2)
["2"]=>
int(3)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
object(stdClass)#1 (3) {
["0"]=>
int(1)
["1"]=>
int(2)
["2"]=>
int(3)
}