mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Add SplStack, SplHeap, SplMinHeap, SplMaxHeap, SplPriorityQueue stubs (#4255)
* Add SplStack, SplHeap, SplMinHeap, SplMaxHeap, SplPriorityQueue stubs * Add SplFixedArray
This commit is contained in:
parent
19f88a2e31
commit
1eca537209
@ -1003,7 +1003,7 @@ class DOMNamedNodeMap implements Traversable, Countable {
|
||||
* @template TKey
|
||||
* @template TValue
|
||||
* @template-implements Iterator<TKey, TValue>
|
||||
* @template-implements ArrayAccess<TKey, TValue>
|
||||
* @template-implements ArrayAccess<TKey, TValue>
|
||||
*/
|
||||
class SplDoublyLinkedList implements Iterator, Countable, ArrayAccess, Serializable
|
||||
{
|
||||
@ -1169,6 +1169,184 @@ class SplDoublyLinkedList implements Iterator, Countable, ArrayAccess, Serializa
|
||||
public function key() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* The SplFixedArray class provides the main functionalities of array.
|
||||
* The main differences between a SplFixedArray and a normal PHP array is that
|
||||
* the SplFixedArray is of fixed length and allows only integers within the range as indexes.
|
||||
* The advantage is that it uses less memory than a standard array.
|
||||
*
|
||||
* @link https://php.net/manual/en/class.splfixedarray.php
|
||||
*
|
||||
* @template TValue
|
||||
* @template-implements ArrayAccess<int, TValue>
|
||||
* @template-implements Iterator<int, TValue>
|
||||
*/
|
||||
class SplFixedArray implements Iterator, ArrayAccess, Countable {
|
||||
/**
|
||||
* Constructs a new fixed array
|
||||
*
|
||||
* Initializes a fixed array with a number of NULL values equal to size.
|
||||
* @link https://php.net/manual/en/splfixedarray.construct.php
|
||||
*
|
||||
* @param int $size The size of the fixed array. This expects a number between 0 and PHP_INT_MAX.
|
||||
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function __construct(int $size = 0) {}
|
||||
|
||||
/**
|
||||
* Import a PHP array in a new SplFixedArray instance
|
||||
* @link https://php.net/manual/en/splfixedarray.fromarray.php
|
||||
*
|
||||
* @template TInValue
|
||||
* @param array<int, TInValue> $array The array to import
|
||||
* @param bool $save_indexes [optional] Try to save the numeric indexes used in the original array.
|
||||
*
|
||||
* @return SplFixedArray<TInValue> Instance of SplFixedArray containing the array content
|
||||
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public static function fromArray(array $array, bool $save_indexes = true): SplFixedArray {}
|
||||
|
||||
/**
|
||||
* Returns a PHP array from the fixed array
|
||||
* @link https://php.net/manual/en/splfixedarray.toarray.php
|
||||
*
|
||||
* @return array<int, TValue>
|
||||
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function toArray(): array {}
|
||||
|
||||
/**
|
||||
* Returns the size of the array.
|
||||
* @link https://php.net/manual/en/splfixedarray.getsize.php
|
||||
*
|
||||
* @return int The size of the array
|
||||
|
||||
* @see SplFixedArray::count()
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function getSize(): int {}
|
||||
|
||||
/**
|
||||
* Returns the size of the array.
|
||||
* @link https://php.net/manual/en/splfixedarray.count.php
|
||||
*
|
||||
* @return int The size of the array
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function count(): int {}
|
||||
|
||||
/**
|
||||
* Rewind the iterator back to the start
|
||||
* @link https://php.net/manual/en/splfixedarray.rewind.php
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function rewind(): void {}
|
||||
|
||||
/**
|
||||
* Check whether the array contains more elements
|
||||
* @link https://php.net/manual/en/splfixedarray.valid.php
|
||||
*
|
||||
* @return bool true if the array contains any more elements, false otherwise.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function valid(): bool {}
|
||||
|
||||
/**
|
||||
* Returns current array index
|
||||
* @link https://php.net/manual/en/splfixedarray.key.php
|
||||
*
|
||||
* @return int The current array index
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function key(): int {}
|
||||
|
||||
/**
|
||||
* Returns the current array entry
|
||||
* @link https://php.net/manual/en/splfixedarray.current.php
|
||||
*
|
||||
* @return TValue The current element value
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function current() {}
|
||||
|
||||
/**
|
||||
* Move to the next entry
|
||||
* @link https://php.net/manual/en/splfixedarray.next.php
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function next(): void {}
|
||||
|
||||
/**
|
||||
* Returns whether the specified index exists
|
||||
* @link https://php.net/manual/en/splfixedarray.offsetexists.php
|
||||
*
|
||||
* @param int $index The index being checked.
|
||||
* @return bool true if the requested index exists, and false otherwise.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function offsetExists(int $index): bool {}
|
||||
|
||||
/**
|
||||
* Sets a new value at a specified index
|
||||
* @link https://php.net/manual/en/splfixedarray.offsetset.php
|
||||
*
|
||||
* @param int $index The index being sent.
|
||||
* @param TValue $newval The new value for the index
|
||||
* @return void
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function offsetSet(int $index, $newval): void {}
|
||||
|
||||
/**
|
||||
* Unsets the value at the specified $index
|
||||
* @link https://php.net/manual/en/splfixedarray.offsetunset.php
|
||||
*
|
||||
* @param int $index The index being unset
|
||||
* @return void
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function offsetUnset(int $index): void {}
|
||||
|
||||
/**
|
||||
* Returns the value at the specified index
|
||||
* @link https://php.net/manual/en/splfixedarray.offsetget.php
|
||||
*
|
||||
* @param int $index The index with the value
|
||||
* @return TValue The value at the specified index
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function offsetGet(int $index) {}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The SplStack class provides the main functionalities of a stack implemented using a doubly linked list.
|
||||
* @link https://php.net/manual/en/class.splstack.php
|
||||
*
|
||||
* @template TValue
|
||||
* @template-extends SplDoublyLinkedList<int, TValue>
|
||||
*/
|
||||
class SplStack extends SplDoublyLinkedList {
|
||||
}
|
||||
|
||||
/**
|
||||
* The SplQueue class provides the main functionalities of a queue implemented using a doubly linked list.
|
||||
* @link https://php.net/manual/en/class.splqueue.php
|
||||
@ -1199,6 +1377,355 @@ class SplQueue extends SplDoublyLinkedList {
|
||||
public function dequeue() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* The SplHeap class provides the main functionalities of a Heap.
|
||||
* @link https://php.net/manual/en/class.splheap.php
|
||||
*
|
||||
* @template TValue
|
||||
* @template-implements Iterator<int, TValue>
|
||||
*/
|
||||
class SplHeap implements Iterator, Countable {
|
||||
public function __construct() {}
|
||||
|
||||
/**
|
||||
* Compare elements in order to place them correctly in the heap while sifting up
|
||||
* @link https://php.net/manual/en/splheap.compare.php
|
||||
*
|
||||
* @param TValue $value1 The value of the first node being compared.
|
||||
* @param TValue $value2 The value of the second node being compared.
|
||||
* @return int Positive integer if value1 is greater than value2, 0 if they are equal, negative integer otherwise.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
protected abstract function compare($value1, $value2): int {}
|
||||
|
||||
/**
|
||||
* Counts the number of elements in the heap
|
||||
* @link https://php.net/manual/en/splheap.count.php
|
||||
*
|
||||
* @return int The number of elements in the heap.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function count(): int {}
|
||||
|
||||
/**
|
||||
* Get the current datastructure node.
|
||||
* @link https://php.net/manual/en/splheap.current.php
|
||||
*
|
||||
* @return TValue The current node value
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function current() {}
|
||||
|
||||
/**
|
||||
* Extracts a node from top of the heap and sift up
|
||||
* @link https://php.net/manual/en/splheap.extract.php
|
||||
*
|
||||
* @return TValue The current node value
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function extract() {}
|
||||
|
||||
/**
|
||||
* Inserts an element in the heap by sifting it up
|
||||
* @link https://php.net/manual/en/splheap.insert.php
|
||||
*
|
||||
* @param TValue $value The value to insert.
|
||||
* @return void
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function insert($value): void {}
|
||||
|
||||
/**
|
||||
* Tells if the heap is in a corrupted state
|
||||
* @link https://php.net/manual/en/splheap.isCorrupted.php
|
||||
*
|
||||
* @return bool true if the heap is corrupted, false otherwise.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
public function isCorrupted(): bool {}
|
||||
|
||||
/**
|
||||
* Checks whether the heap is empty
|
||||
* @link https://php.net/manual/en/splheap.isEmpty.php
|
||||
*
|
||||
* @return bool Whether the heap is empty
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function isEmpty(): bool {}
|
||||
|
||||
/**
|
||||
* Return current node index
|
||||
* @link https://php.net/manual/en/splheap.key.php
|
||||
*
|
||||
* @return int The current node index
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function key() {}
|
||||
|
||||
/**
|
||||
* Move to the next node. This will delete the top node of the heap.
|
||||
* @link https://php.net/manual/en/splheap.next.php
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function next(): void {}
|
||||
|
||||
/**
|
||||
* Recover from the corrupted state and allow further actions on the heap
|
||||
* @link https://php.net/manual/en/splheap.recoverFromCorruption.php
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function recoverFromCorruption(): void {}
|
||||
|
||||
/**
|
||||
* Rewind iterator back to the start (no-op)
|
||||
* @link https://php.net/manual/en/splheap.rewind.php
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function rewind(): void {}
|
||||
|
||||
/**
|
||||
* Peeks at the node from the top of the heap
|
||||
* @link https://php.net/manual/en/splheap.top.php
|
||||
*
|
||||
* @return TValue The value of the node on the top.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function top() {}
|
||||
|
||||
/**
|
||||
* Check whether the heap contains any more nodes
|
||||
* @link https://php.net/manual/en/splheap.valid.php
|
||||
*
|
||||
* @return bool Returns true if the heap contains any more nodes, false otherwise.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function valid(): bool {}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The SplMaxHeap class provides the main functionalities of a heap, keeping the maximum on the top.
|
||||
* @link https://php.net/manual/en/class.splmaxheap.php
|
||||
*
|
||||
* @template TValue
|
||||
* @template-extends SplHeap<TValue>
|
||||
*/
|
||||
class SplMaxHeap extends SplHeap {
|
||||
}
|
||||
|
||||
/**
|
||||
* The SplMinHeap class provides the main functionalities of a heap, keeping the maximum on the top.
|
||||
* @link https://php.net/manual/en/class.splminheap.php
|
||||
*
|
||||
* @template TValue
|
||||
* @template-extends SplHeap<TValue>
|
||||
*/
|
||||
class SplMinHeap extends SplHeap {
|
||||
}
|
||||
|
||||
/**
|
||||
* The SplPriorityQueue class provides the main functionalities of a prioritized queue, implemented using a max heap.
|
||||
* @link https://php.net/manual/en/class.splpriorityqueue.php
|
||||
*
|
||||
* @template TValue
|
||||
* @template TPriority
|
||||
* @template-implements Iterator<int, TValue>
|
||||
*/
|
||||
class SplPriorityQueue implements Iterator, Countable {
|
||||
/**
|
||||
* Extract the data
|
||||
*/
|
||||
const EXTR_DATA = 0x00000001;
|
||||
/**
|
||||
* Extract the priority
|
||||
*/
|
||||
const EXTR_PRIORITY = 0x00000002;
|
||||
/**
|
||||
* Extract an array containing both
|
||||
*/
|
||||
const EXTR_BOTH = 0x00000003;
|
||||
|
||||
public function __construct() {}
|
||||
|
||||
/**
|
||||
* Compare priorities in order to place them correctly in the queue while sifting up
|
||||
* @link https://php.net/manual/en/splpriorityqueue.compare.php
|
||||
*
|
||||
* @param TValue $priority1 The priority of the first node being compared.
|
||||
* @param TValue $priority2 The priority of the second node being compared.
|
||||
* @return int Positive integer if priority1 is greater than priority2, 0 if they are equal, negative integer otherwise.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function compare($priority1, $priority2): int {}
|
||||
|
||||
/**
|
||||
* Counts the number of elements in the queue
|
||||
* @link https://php.net/manual/en/splpriorityqueue.count.php
|
||||
*
|
||||
* @return int The number of elements in the queue.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function count(): int {}
|
||||
|
||||
/**
|
||||
* Get the current datastructure node.
|
||||
* @link https://php.net/manual/en/splpriorityqueue.current.php
|
||||
*
|
||||
* @return TValue The current node value
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function current() {}
|
||||
|
||||
/**
|
||||
* Extracts a node from top of the queue and sift up
|
||||
* @link https://php.net/manual/en/splpriorityqueue.extract.php
|
||||
*
|
||||
* @return TValue The current node value
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function extract() {}
|
||||
|
||||
/**
|
||||
* Get the flags of extraction
|
||||
* @link https://php.net/manual/en/splpriorityqueue.getextractflags.php
|
||||
*
|
||||
* @return SplPriorityQueue::EXTR_* Returns the current extraction mode
|
||||
*
|
||||
* @see SplPriorityQueue::setExtractFlags
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function getExtractFlags(): int {}
|
||||
|
||||
/**
|
||||
* Inserts an element in the queue by sifting it up
|
||||
* @link https://php.net/manual/en/splpriorityqueue.insert.php
|
||||
*
|
||||
* @param TValue $value The value to insert.
|
||||
* @param TPriority $priority The associated priority.
|
||||
* @return true
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function insert($value, $priority): bool {}
|
||||
|
||||
/**
|
||||
* Tells if the queue is in a corrupted state
|
||||
* @link https://php.net/manual/en/splpriorityqueue.isCorrupted.php
|
||||
*
|
||||
* @return bool true if the queue is corrupted, false otherwise.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
public function isCorrupted(): bool {}
|
||||
|
||||
/**
|
||||
* Checks whether the queue is empty
|
||||
* @link https://php.net/manual/en/splpriorityqueue.isEmpty.php
|
||||
*
|
||||
* @return bool Whether the queue is empty
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function isEmpty(): bool {}
|
||||
|
||||
/**
|
||||
* Return current node index
|
||||
* @link https://php.net/manual/en/splpriorityqueue.key.php
|
||||
*
|
||||
* @return int The current node index
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function key() {}
|
||||
|
||||
/**
|
||||
* Move to the next node.
|
||||
* @link https://php.net/manual/en/splpriorityqueue.next.php
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function next(): void {}
|
||||
|
||||
/**
|
||||
* Recover from the corrupted state and allow further actions on the queue
|
||||
* @link https://php.net/manual/en/splpriorityqueue.recoverFromCorruption.php
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function recoverFromCorruption(): void {}
|
||||
|
||||
/**
|
||||
* Rewind iterator back to the start (no-op)
|
||||
* @link https://php.net/manual/en/splpriorityqueue.rewind.php
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function rewind(): void {}
|
||||
|
||||
/**
|
||||
* Sets the mode of extraction
|
||||
* @link https://php.net/manual/en/splpriorityqueue.setextractflags.php
|
||||
*
|
||||
* @param SplPriorityQueue::EXTR_* $flags Defines what is extracted by SplPriorityQueue::current(), SplPriorityQueue::top() and SplPriorityQueue::extract().
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function setExtractFlags(int $flags): void {}
|
||||
|
||||
/**
|
||||
* Peeks at the node from the top of the queue
|
||||
* @link https://php.net/manual/en/splpriorityqueue.top.php
|
||||
*
|
||||
* @return TValue The value of the node on the top.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function top() {}
|
||||
|
||||
/**
|
||||
* Check whether the queue contains any more nodes
|
||||
* @link https://php.net/manual/en/splpriorityqueue.valid.php
|
||||
*
|
||||
* @return bool Returns true if the queue contains any more nodes, false otherwise.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public function valid(): bool {}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The SplObjectStorage class provides a map from objects to data or, by
|
||||
* ignoring data, an object set. This dual purpose can be useful in many
|
||||
|
Loading…
Reference in New Issue
Block a user