File tree Expand file tree Collapse file tree 4 files changed +42
-6
lines changed Expand file tree Collapse file tree 4 files changed +42
-6
lines changed Original file line number Diff line number Diff line change 80
80
note that reading and writing a value inside a single expression remains
81
81
undefined behavior and may change again in the future.
82
82
83
+ . Argument unpacking stopped working with Traversables with non-integer keys.
84
+ The following code worked in PHP 7.0-7.2 by accident.
85
+
86
+ function foo(...$args) {
87
+ var_dump($args);
88
+ }
89
+ function gen() {
90
+ yield 1.23 => 123;
91
+ }
92
+ foo(...gen());
93
+
94
+ Now it generates an exception.
95
+
83
96
BCMath:
84
97
. All warnings thrown by BCMath functions are now using PHP's error handling.
85
98
Formerly some warnings have directly been written to stderr.
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Argument unpacking does not work with non-integer keys
3
+ --FILE--
4
+ <?php
5
+ function foo (...$ args ) {
6
+ var_dump ($ args );
7
+ }
8
+ function gen () {
9
+ yield 1.23 => 123 ;
10
+ yield "2.34 " => 234 ;
11
+ }
12
+
13
+ try {
14
+ foo (...gen ());
15
+ } catch (Error $ ex ) {
16
+ echo "Exception: " . $ ex ->getMessage () . "\n" ;
17
+ }
18
+
19
+ ?>
20
+ --EXPECT--
21
+ Exception: Cannot unpack Traversable with non-integer keys
Original file line number Diff line number Diff line change @@ -4522,10 +4522,11 @@ ZEND_VM_C_LABEL(send_again):
4522
4522
}
4523
4523
4524
4524
if (UNEXPECTED (Z_TYPE (key ) != IS_LONG )) {
4525
- ZEND_ASSERT (Z_TYPE (key ) == IS_STRING );
4526
4525
zend_throw_error (NULL ,
4527
- "Cannot unpack Traversable with string keys" );
4528
- zval_ptr_dtor_str (& key );
4526
+ (Z_TYPE (key ) == IS_STRING ) ?
4527
+ "Cannot unpack Traversable with string keys" :
4528
+ "Cannot unpack Traversable with non-integer keys" );
4529
+ zval_ptr_dtor (& key );
4529
4530
break ;
4530
4531
}
4531
4532
}
Original file line number Diff line number Diff line change @@ -1359,10 +1359,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_UNPACK_SPEC_HANDLER(ZEND_
1359
1359
}
1360
1360
1361
1361
if (UNEXPECTED(Z_TYPE(key) != IS_LONG)) {
1362
- ZEND_ASSERT(Z_TYPE(key) == IS_STRING);
1363
1362
zend_throw_error(NULL,
1364
- "Cannot unpack Traversable with string keys");
1365
- zval_ptr_dtor_str(&key);
1363
+ (Z_TYPE(key) == IS_STRING) ?
1364
+ "Cannot unpack Traversable with string keys" :
1365
+ "Cannot unpack Traversable with non-integer keys");
1366
+ zval_ptr_dtor(&key);
1366
1367
break;
1367
1368
}
1368
1369
}
You can’t perform that action at this time.
0 commit comments