Skip to content

Commit

Permalink
Fix template param for SplDoublyLinkedList.
Browse files Browse the repository at this point in the history
It's key is always an integer.
  • Loading branch information
ADmad committed Oct 13, 2022
1 parent 7ec5ffb commit 142c9a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/annotating_code/templated_annotations.md
Expand Up @@ -448,5 +448,5 @@ Psalm has support for a number of builtin classes and interfaces that you can ex
- `class ArrayObject<TKey, TValue> implements IteratorAggregate<TKey, TValue>, ArrayAccess<TKey, TValue>`
- `class ArrayIterator<TKey of array-key, TValue> implements SeekableIterator<TKey, TValue>, ArrayAccess<TKey, TValue>`
- `class DOMNodeList<TNode of DOMNode> implements Traversable<int, TNode>`
- `class SplDoublyLinkedList<TKey, TValue> implements Iterator<TKey, TValue>, ArrayAccess<TKey, TValue>`
- `class SplQueue<TValue> extends SplDoublyLinkedList<int, TValue>`
- `class SplDoublyLinkedList<TValue> implements Iterator<TKey, TValue>, ArrayAccess<TKey, TValue>`
- `class SplQueue<TValue> extends SplDoublyLinkedList<TValue>`
9 changes: 4 additions & 5 deletions stubs/SPL.phpstub
Expand Up @@ -4,10 +4,9 @@
* The SplDoublyLinkedList class provides the main functionalities of a doubly linked list.
* @link https://php.net/manual/en/class.spldoublylinkedlist.php
*
* @template TKey
* @template TValue
* @template-implements Iterator<TKey, TValue>
* @template-implements ArrayAccess<TKey, TValue>
* @template-implements Iterator<int, TValue>
* @template-implements ArrayAccess<int, TValue>
*/
class SplDoublyLinkedList implements Iterator, Countable, ArrayAccess, Serializable
{
Expand Down Expand Up @@ -346,7 +345,7 @@ class SplFixedArray implements Iterator, ArrayAccess, Countable {
* @link https://php.net/manual/en/class.splstack.php
*
* @template TValue
* @template-extends SplDoublyLinkedList<int, TValue>
* @template-extends SplDoublyLinkedList<TValue>
*/
class SplStack extends SplDoublyLinkedList {
}
Expand All @@ -356,7 +355,7 @@ class SplStack extends SplDoublyLinkedList {
* @link https://php.net/manual/en/class.splqueue.php
*
* @template TValue
* @template-extends SplDoublyLinkedList<int, TValue>
* @template-extends SplDoublyLinkedList<TValue>
*/
class SplQueue extends SplDoublyLinkedList {
/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Template/ClassTemplateTest.php
Expand Up @@ -1022,7 +1022,7 @@ public function partition() {}
$list->add(5, "hello");
$list->add("hello", 5);
/** @var SplDoublyLinkedList<int, string> */
/** @var SplDoublyLinkedList<string> */
$templated_list = new SplDoublyLinkedList();
$templated_list->add(5, "hello");
$a = $templated_list->bottom();',
Expand Down Expand Up @@ -3981,7 +3981,7 @@ function violate($p) {}',
],
'doublyLinkedListBadParam' => [
'<?php
/** @var SplDoublyLinkedList<int, string> */
/** @var SplDoublyLinkedList<string> */
$templated_list = new SplDoublyLinkedList();
$templated_list->add(5, []);',
'error_message' => 'InvalidArgument',
Expand Down

0 comments on commit 142c9a4

Please sign in to comment.