mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00

This adds support for: $array1 = ['a' => 1, 'b' => 2]; $array2 = ['b' => 3, 'c' => 4]; $array = [...$array1, ...$array2]; // => ['a' => 1, 'b' => 3, 'c' => 4] RFC: https://wiki.php.net/rfc/array_unpacking_string_keys Closes GH-6584.
18 lines
323 B
PHP
18 lines
323 B
PHP
--TEST--
|
|
Array unpacking does not work with non-integer/string keys
|
|
--FILE--
|
|
<?php
|
|
function gen() {
|
|
yield [] => 1;
|
|
yield 1.23 => 123;
|
|
}
|
|
|
|
try {
|
|
[...gen()];
|
|
} catch (Error $ex) {
|
|
echo "Exception: " . $ex->getMessage() . "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
Exception: Keys must be of type int|string during array unpacking
|