Skip to content

Commit d28b61b

Browse files
committed
Narrow down type T of RecursiveIteratorIterator
1 parent d29d098 commit d28b61b

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

stubs/iterable.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class ArrayIterator implements SeekableIterator, ArrayAccess, Countable
138138
}
139139

140140
/**
141-
* @template T of \Traversable
141+
* @template T of \RecursiveIterator|\IteratorAggregate
142142
* @mixin T
143143
*/
144144
class RecursiveIteratorIterator

tests/PHPStan/Rules/Classes/InstantiationRuleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,14 @@ public function testBug1711(): void
332332
$this->analyse([__DIR__ . '/data/bug-1711.php'], []);
333333
}
334334

335+
public function testBug3425(): void
336+
{
337+
$this->analyse([__DIR__ . '/data/bug-3425.php'], [
338+
[
339+
'Parameter #1 $it of class RecursiveIteratorIterator constructor expects T of IteratorAggregate|RecursiveIterator, Generator<int, int, mixed, void> given.',
340+
5,
341+
],
342+
]);
343+
}
344+
335345
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug3425;
4+
5+
new \RecursiveIteratorIterator((function() { yield 22; })());

0 commit comments

Comments
 (0)