Skip to content

Commit 2d1cac0

Browse files
committed
Stub with @mixin for RecursiveIteratorIterator
1 parent 3bc8d7f commit 2d1cac0

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

stubs/iterable.stub

+23
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,26 @@ class DOMNodeList implements Traversable
176176
public function item ($index) {}
177177

178178
}
179+
180+
/**
181+
* @template T
182+
* @mixin T
183+
*/
184+
class RecursiveIteratorIterator
185+
{
186+
187+
/**
188+
* @param T $iterator
189+
* @param int $mode
190+
* @param int $flags
191+
*/
192+
public function __construct(
193+
$iterator,
194+
$mode = RecursiveIteratorIterator::LEAVES_ONLY,
195+
int $flags = 0
196+
)
197+
{
198+
199+
}
200+
201+
}

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -1275,4 +1275,17 @@ public function testMixin(): void
12751275
]);
12761276
}
12771277

1278+
public function testRecursiveIteratorIterator(): void
1279+
{
1280+
$this->checkThisOnly = false;
1281+
$this->checkNullables = true;
1282+
$this->checkUnionTypes = true;
1283+
$this->analyse([__DIR__ . '/data/recursive-iterator-iterator.php'], [
1284+
[
1285+
'Method RecursiveDirectoryIterator::getSubPathname() invoked with 1 parameter, 0 required.',
1286+
14,
1287+
],
1288+
]);
1289+
}
1290+
12781291
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace RecursiveIteratorIteratorMixin;
4+
5+
class Foo
6+
{
7+
8+
public function doFoo(): void
9+
{
10+
$it = new \RecursiveDirectoryIterator(__DIR__);
11+
$it = new \RecursiveIteratorIterator($it);
12+
foreach ($it as $_) {
13+
echo $it->getSubPathname();
14+
echo $it->getSubPathname(1);
15+
}
16+
}
17+
18+
}

0 commit comments

Comments
 (0)