diff --git a/stubs/iterable.stub b/stubs/iterable.stub index 2e10bf3889..5cefe2f196 100644 --- a/stubs/iterable.stub +++ b/stubs/iterable.stub @@ -403,6 +403,11 @@ class CachingIterator extends IteratorIterator implements OuterIterator, ArrayAc * @return TKey */ public function key() {} + + /** + * @return array + */ + public function getCache() {} } /** diff --git a/tests/PHPStan/Analyser/NodeScopeResolverTest.php b/tests/PHPStan/Analyser/NodeScopeResolverTest.php index 122089b4d4..889acc4b7b 100644 --- a/tests/PHPStan/Analyser/NodeScopeResolverTest.php +++ b/tests/PHPStan/Analyser/NodeScopeResolverTest.php @@ -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'); } /** diff --git a/tests/PHPStan/Analyser/data/bug-1519.php b/tests/PHPStan/Analyser/data/bug-1519.php new file mode 100644 index 0000000000..7d01391c63 --- /dev/null +++ b/tests/PHPStan/Analyser/data/bug-1519.php @@ -0,0 +1,22 @@ + + */ + static function (): Generator { + yield true => true; + yield false => false; + }; + +$iterator = new CachingIterator($generator(), CachingIterator::FULL_CACHE); +$cache = $iterator->getCache(); +assertType('array', $cache);