|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Weak maps allow creating a map from objects to arbitrary values |
| 4 | + * (similar to SplObjectStorage) without preventing the objects that are used |
| 5 | + * as keys from being garbage collected. If an object key is garbage collected, |
| 6 | + * it will simply be removed from the map. |
| 7 | + * |
| 8 | + * @since 8.0 |
| 9 | + * @source https://github.com/JetBrains/phpstorm-stubs/blob/master/Core/Core_c.php |
| 10 | + * |
| 11 | + * @template TKey of object |
| 12 | + * @template TValue |
| 13 | + * @template-implements IteratorAggregate<TKey, TValue> |
| 14 | + */ |
| 15 | +final class WeakMap implements ArrayAccess, Countable, IteratorAggregate { |
| 16 | + /** |
| 17 | + * Returns {@see true} if the value for the object is contained in |
| 18 | + * the {@see WeakMap} and {@see false} instead. |
| 19 | + * |
| 20 | + * @param TKey $object Any object |
| 21 | + * @return bool |
| 22 | + */ |
| 23 | + public function offsetExists($object): bool {} |
| 24 | + |
| 25 | + /** |
| 26 | + * Returns the existsing value by an object. |
| 27 | + * |
| 28 | + * @param TKey $object Any object |
| 29 | + * @return TValue Value associated with the key object |
| 30 | + */ |
| 31 | + public function offsetGet($object): mixed {} |
| 32 | + |
| 33 | + /** |
| 34 | + * Sets a new value for an object. |
| 35 | + * |
| 36 | + * @param TKey $object Any object |
| 37 | + * @param TValue $value Any value |
| 38 | + * @return void |
| 39 | + */ |
| 40 | + public function offsetSet($object, mixed $value): void {} |
| 41 | + |
| 42 | + /** |
| 43 | + * Force removes an object value from the {@see WeakMap} instance. |
| 44 | + * |
| 45 | + * @param TKey $object Any object |
| 46 | + * @return void |
| 47 | + */ |
| 48 | + public function offsetUnset($object): void {} |
| 49 | + |
| 50 | + /** |
| 51 | + * Returns an iterator in the "[object => mixed]" format. |
| 52 | + * |
| 53 | + * @return Traversable<TKey, TValue> |
| 54 | + */ |
| 55 | + public function getIterator(): Iterator {} |
| 56 | + |
| 57 | + /** |
| 58 | + * Returns the number of items in the {@see WeakMap} instance. |
| 59 | + * |
| 60 | + * @return int |
| 61 | + */ |
| 62 | + public function count(): int {} |
| 63 | +} |
0 commit comments