Changed error message, added UPGRADING note and test.
note that reading and writing a value inside a single expression remains
undefined behavior and may change again in the future.
+ . Argument unpacking stopped working with Traversables with non-integer keys.
+ The following code worked in PHP 7.0-7.2 by accident.
+
+ function foo(...$args) {
+ var_dump($args);
+ }
+ function gen() {
+ yield 1.23 => 123;
+ }
+ foo(...gen());
+
+ Now it generates an exception.
+
BCMath:
. All warnings thrown by BCMath functions are now using PHP's error handling.
Formerly some warnings have directly been written to stderr.
--- /dev/null
+--TEST--
+Argument unpacking does not work with non-integer keys
+--FILE--
+<?php
+function foo(...$args) {
+ var_dump($args);
+}
+function gen() {
+ yield 1.23 => 123;
+ yield "2.34" => 234;
+}
+
+try {
+ foo(...gen());
+} catch (Error $ex) {
+ echo "Exception: " . $ex->getMessage() . "\n";
+}
+
+?>
+--EXPECT--
+Exception: Cannot unpack Traversable with non-integer keys
}
if (UNEXPECTED(Z_TYPE(key) != IS_LONG)) {
- ZEND_ASSERT(Z_TYPE(key) == IS_STRING);
zend_throw_error(NULL,
- "Cannot unpack Traversable with string keys");
- zval_ptr_dtor_str(&key);
+ (Z_TYPE(key) == IS_STRING) ?
+ "Cannot unpack Traversable with string keys" :
+ "Cannot unpack Traversable with non-integer keys");
+ zval_ptr_dtor(&key);
break;
}
}
}
if (UNEXPECTED(Z_TYPE(key) != IS_LONG)) {
- ZEND_ASSERT(Z_TYPE(key) == IS_STRING);
zend_throw_error(NULL,
- "Cannot unpack Traversable with string keys");
- zval_ptr_dtor_str(&key);
+ (Z_TYPE(key) == IS_STRING) ?
+ "Cannot unpack Traversable with string keys" :
+ "Cannot unpack Traversable with non-integer keys");
+ zval_ptr_dtor(&key);
break;
}
}