1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Add IteratorIterator generics

This commit is contained in:
Matthew Brown 2020-01-24 08:58:52 -05:00
parent c87b19eeb0
commit c893bd6a6b

View File

@ -96,6 +96,80 @@ interface Iterator extends Traversable {
public function rewind();
}
/**
* @template-covariant TKey
* @template-covariant TValue
*
* @template-extends Iterator<TKey, TValue>
*/
interface OuterIterator extends Iterator {
/**
* @return Iterator<TKey, TValue>
*/
public function getInnerIterator() : Iterator;
}
/**
* @template-covariant TKey
* @template-covariant TValue
*
* @template-extends OuterIterator<TKey, TValue>
*/
class IteratorIterator implements OuterIterator {
/**
* @return Iterator<TKey, TValue>
*/
public function getInnerIterator() : Iterator {}
/**
* Return the current element
* @link http://php.net/manual/en/iterator.current.php
*
* @return TValue Can return any type.
*
* @since 5.0.0
*/
public function current() {}
/**
* Move forward to next element
* @link http://php.net/manual/en/iterator.next.php
*
* @return void Any returned value is ignored.
*
* @since 5.0.0
*/
public function next() {}
/**
* Return the key of the current element
* @link http://php.net/manual/en/iterator.key.php
*
* @return TKey scalar on success, or null on failure.
*
* @since 5.0.0
*/
public function key() {}
/**
* @return bool The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
*
* @since 5.0.0
*/
public function valid() {}
/**
* Rewind the Iterator to the first element
* @link http://php.net/manual/en/iterator.rewind.php
*
* @return void Any returned value is ignored.
*
* @since 5.0.0
*/
public function rewind() {}
}
/**
* @template-covariant TKey
* @template-covariant TValue