Add generics for LoopIterator

This makes it possible for PHPStan to understand what happens when iterating.
This commit is contained in:
Ruud Kamphuis
2024-09-26 20:21:01 +02:00
parent 355a80c5df
commit a4dc388c62
+7
View File
@@ -19,6 +19,10 @@ use Twig\Error\RuntimeError;
* @author Fabien Potencier <fabien@symfony.com>
*
* @internal
*
* @template TKey
* @template TValue
* @implements \Iterator<TKey, TValue>
*/
final class LoopIterator implements \Iterator
{
@@ -32,6 +36,9 @@ final class LoopIterator implements \Iterator
/** @var array{valid: bool, key: mixed, value: mixed}|null */
private ?array $next = null;
/**
* @param iterable<TKey, TValue> $seq
*/
public function __construct($seq)
{
if (\is_array($seq)) {