diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-02-26 16:42:49 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-06-24 15:31:41 +0200 |
commit | ff19ec2df3ef0dca8c29be83eddcde58234f4095 (patch) | |
tree | bc6477f4f4e696cf599ec82a0a6dbf221bc5bc10 /ext/mysqli/mysqli.c | |
parent | 4730b06f1d026047c63980298d358e28e2183de6 (diff) | |
download | php-git-ff19ec2df3ef0dca8c29be83eddcde58234f4095.tar.gz |
Introduce InternalIterator
Userland classes that implement Traversable must do so either
through Iterator or IteratorAggregate. The same requirement does
not exist for internal classes: They can implement the internal
get_iterator mechanism, without exposing either the Iterator or
IteratorAggregate APIs. This makes them usable in get_iterator(),
but incompatible with any Iterator based APIs.
A lot of internal classes do this, because exposing the userland
APIs is simply a lot of work. This patch alleviates this issue by
providing a generic InternalIterator class, which acts as an
adapater between get_iterator and Iterator, and can be easily
used by many internal classes. At the same time, we extend the
requirement that Traversable implies Iterator or IteratorAggregate
to internal classes as well.
Closes GH-5216.
Diffstat (limited to 'ext/mysqli/mysqli.c')
-rw-r--r-- | ext/mysqli/mysqli.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index eb3c79b798..ec7d296b24 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -636,7 +636,7 @@ PHP_MINIT_FUNCTION(mysqli) zend_declare_property_null(ce, "num_rows", sizeof("num_rows") - 1, ZEND_ACC_PUBLIC); zend_declare_property_null(ce, "type", sizeof("type") - 1, ZEND_ACC_PUBLIC); mysqli_result_class_entry->get_iterator = php_mysqli_result_get_iterator; - zend_class_implements(mysqli_result_class_entry, 1, zend_ce_traversable); + zend_class_implements(mysqli_result_class_entry, 1, zend_ce_aggregate); zend_hash_add_ptr(&classes, ce->name, &mysqli_result_properties); REGISTER_MYSQLI_CLASS_ENTRY("mysqli_stmt", mysqli_stmt_class_entry, class_mysqli_stmt_methods); @@ -1087,6 +1087,15 @@ PHP_FUNCTION(mysqli_result_construct) } /* }}} */ +PHP_METHOD(mysqli_result, getIterator) +{ + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + zend_create_internal_iterator_zval(return_value, ZEND_THIS); +} + /* {{{ php_mysqli_fetch_into_hash_aux */ void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, zend_long fetchtype) |