mirror of
https://github.com/php/php-src.git
synced 2024-12-17 05:50:14 +08:00
Merge branch 'PHP-8.0'
* PHP-8.0: Handle ref return from Iterator::key()
This commit is contained in:
commit
7af3a392f1
15
Zend/tests/iterator_key_by_ref.phpt
Normal file
15
Zend/tests/iterator_key_by_ref.phpt
Normal file
@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Iterator::key() with by-ref return
|
||||
--FILE--
|
||||
<?php
|
||||
class Test extends ArrayIterator {
|
||||
function &key() {
|
||||
return $foo;
|
||||
}
|
||||
}
|
||||
foreach (new Test([0]) as $k => $v) {
|
||||
var_dump($k);
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
NULL
|
@ -154,6 +154,9 @@ ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *ke
|
||||
zend_user_iterator *iter = (zend_user_iterator*)_iter;
|
||||
zval *object = &iter->it.data;
|
||||
zend_call_method_with_0_params(Z_OBJ_P(object), iter->ce, &iter->ce->iterator_funcs_ptr->zf_key, "key", key);
|
||||
if (UNEXPECTED(Z_ISREF_P(key))) {
|
||||
zend_unwrap_reference(key);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user