mirror of
https://github.com/php/php-src.git
synced 2024-12-19 15:00:15 +08:00
a0502b89a6
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().
48 lines
524 B
PHP
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)
|
|
}
|