From ff19ec2df3ef0dca8c29be83eddcde58234f4095 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Feb 2020 16:42:49 +0100 Subject: 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. --- Zend/zend_weakrefs.stub.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Zend/zend_weakrefs.stub.php') diff --git a/Zend/zend_weakrefs.stub.php b/Zend/zend_weakrefs.stub.php index 4cf189b064..8cf0df5cf6 100644 --- a/Zend/zend_weakrefs.stub.php +++ b/Zend/zend_weakrefs.stub.php @@ -11,7 +11,7 @@ final class WeakReference public function get(): ?object {} } -final class WeakMap implements ArrayAccess, Countable, Traversable +final class WeakMap implements ArrayAccess, Countable, IteratorAggregate { /** * @param object $object @@ -32,4 +32,6 @@ final class WeakMap implements ArrayAccess, Countable, Traversable public function offsetUnset($object): void {} public function count(): int {} + + public function getIterator(): Iterator {} } -- cgit v1.2.1