mirror of
https://github.com/php/php-src.git
synced 2024-09-23 10:57:26 +00:00
ff19ec2df3
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.
38 lines
772 B
PHP
38 lines
772 B
PHP
<?php
|
|
|
|
/** @generate-function-entries */
|
|
|
|
final class WeakReference
|
|
{
|
|
public function __construct() {}
|
|
|
|
public static function create(): WeakReference {}
|
|
|
|
public function get(): ?object {}
|
|
}
|
|
|
|
final class WeakMap implements ArrayAccess, Countable, IteratorAggregate
|
|
{
|
|
/**
|
|
* @param object $object
|
|
* @return mixed
|
|
*/
|
|
public function offsetGet($object) {}
|
|
|
|
/**
|
|
* @param object $object
|
|
* @param mixed $value
|
|
*/
|
|
public function offsetSet($object, $value): void {}
|
|
|
|
/** @param object $object */
|
|
public function offsetExists($object): bool {}
|
|
|
|
/** @param object $object */
|
|
public function offsetUnset($object): void {}
|
|
|
|
public function count(): int {}
|
|
|
|
public function getIterator(): Iterator {}
|
|
}
|