Merge branch 'PHP-8.0'

* PHP-8.0:
  Handle ref return from Iterator::key()
This commit is contained in:
Nikita Popov 2021-04-15 13:06:04 +02:00
commit 7af3a392f1
2 changed files with 18 additions and 0 deletions

View 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

View File

@ -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);
}
}
/* }}} */