Skip to content

Commit 3283eea

Browse files
committed
Added WeakMap stub
- Created WeakMap stub class - Updated phan configuration
1 parent edd8e58 commit 3283eea

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

.phan/config.php

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
'directory_list' => [
5050
'src',
5151
'vendor',
52+
'.phan/stubs',
5253
],
5354

5455
// A directory list that defines files that will be excluded
@@ -64,6 +65,7 @@
6465
// and `exclude_analysis_directory_list` arrays.
6566
'exclude_analysis_directory_list' => [
6667
'vendor',
68+
'.phan/stubs',
6769
],
6870

6971
// If enabled, Phan will warn if **any** type in a method invocation's object

.phan/stubs/WeakMap.php

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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

Comments
 (0)