Skip to content

Commit

Permalink
Update CachingIterator::getCache stub
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jul 18, 2022
1 parent 9a6ebbb commit d866a66
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions stubs/iterable.stub
Expand Up @@ -403,6 +403,11 @@ class CachingIterator extends IteratorIterator implements OuterIterator, ArrayAc
* @return TKey
*/
public function key() {}

/**
* @return array<array-key, TValue>
*/
public function getCache() {}
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Expand Up @@ -927,6 +927,7 @@ public function dataFileAsserts(): iterable
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7580.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/this-subtractable.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/match-expression-inference.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-1519.php');
}

/**
Expand Down
22 changes: 22 additions & 0 deletions tests/PHPStan/Analyser/data/bug-1519.php
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace App;

use Generator;
use CachingIterator;
use function PHPStan\Testing\assertType;

$generator =
/**
* @return Generator<bool, bool>
*/
static function (): Generator {
yield true => true;
yield false => false;
};

$iterator = new CachingIterator($generator(), CachingIterator::FULL_CACHE);
$cache = $iterator->getCache();
assertType('array<bool>', $cache);

0 comments on commit d866a66

Please sign in to comment.