Skip to content

Commit

Permalink
Stub with @mixin for RecursiveIteratorIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 2, 2020
1 parent 3bc8d7f commit 2d1cac0
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
23 changes: 23 additions & 0 deletions stubs/iterable.stub
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,26 @@ class DOMNodeList implements Traversable
public function item ($index) {}

}

/**
* @template T
* @mixin T
*/
class RecursiveIteratorIterator
{

/**
* @param T $iterator
* @param int $mode
* @param int $flags
*/
public function __construct(
$iterator,
$mode = RecursiveIteratorIterator::LEAVES_ONLY,
int $flags = 0
)
{

}

}
13 changes: 13 additions & 0 deletions tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1275,4 +1275,17 @@ public function testMixin(): void
]);
}

public function testRecursiveIteratorIterator(): void
{
$this->checkThisOnly = false;
$this->checkNullables = true;
$this->checkUnionTypes = true;
$this->analyse([__DIR__ . '/data/recursive-iterator-iterator.php'], [
[
'Method RecursiveDirectoryIterator::getSubPathname() invoked with 1 parameter, 0 required.',
14,
],
]);
}

}
18 changes: 18 additions & 0 deletions tests/PHPStan/Rules/Methods/data/recursive-iterator-iterator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace RecursiveIteratorIteratorMixin;

class Foo
{

public function doFoo(): void
{
$it = new \RecursiveDirectoryIterator(__DIR__);
$it = new \RecursiveIteratorIterator($it);
foreach ($it as $_) {
echo $it->getSubPathname();
echo $it->getSubPathname(1);
}
}

}

0 comments on commit 2d1cac0

Please sign in to comment.