Skip to content

Commit

Permalink
Added WeakMap stub
Browse files Browse the repository at this point in the history
- Created WeakMap stub class
- Updated phan configuration
  • Loading branch information
josemmo committed Feb 20, 2022
1 parent edd8e58 commit 3283eea
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
'directory_list' => [
'src',
'vendor',
'.phan/stubs',
],

// A directory list that defines files that will be excluded
Expand All @@ -64,6 +65,7 @@
// and `exclude_analysis_directory_list` arrays.
'exclude_analysis_directory_list' => [
'vendor',
'.phan/stubs',
],

// If enabled, Phan will warn if **any** type in a method invocation's object
Expand Down
63 changes: 63 additions & 0 deletions .phan/stubs/WeakMap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* Weak maps allow creating a map from objects to arbitrary values
* (similar to SplObjectStorage) without preventing the objects that are used
* as keys from being garbage collected. If an object key is garbage collected,
* it will simply be removed from the map.
*
* @since 8.0
* @source https://github.com/JetBrains/phpstorm-stubs/blob/master/Core/Core_c.php
*
* @template TKey of object
* @template TValue
* @template-implements IteratorAggregate<TKey, TValue>
*/
final class WeakMap implements ArrayAccess, Countable, IteratorAggregate {
/**
* Returns {@see true} if the value for the object is contained in
* the {@see WeakMap} and {@see false} instead.
*
* @param TKey $object Any object
* @return bool
*/
public function offsetExists($object): bool {}

/**
* Returns the existsing value by an object.
*
* @param TKey $object Any object
* @return TValue Value associated with the key object
*/
public function offsetGet($object): mixed {}

/**
* Sets a new value for an object.
*
* @param TKey $object Any object
* @param TValue $value Any value
* @return void
*/
public function offsetSet($object, mixed $value): void {}

/**
* Force removes an object value from the {@see WeakMap} instance.
*
* @param TKey $object Any object
* @return void
*/
public function offsetUnset($object): void {}

/**
* Returns an iterator in the "[object => mixed]" format.
*
* @return Traversable<TKey, TValue>
*/
public function getIterator(): Iterator {}

/**
* Returns the number of items in the {@see WeakMap} instance.
*
* @return int
*/
public function count(): int {}
}

0 comments on commit 3283eea

Please sign in to comment.