From 0831a0160c2bbc5a7406c0223f6784ea5bcb9399 Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Thu, 14 Oct 2021 07:46:04 +0300 Subject: [PATCH] Fixed Finder key and value (#221) --- .../common/Component/Finder/Finder.stubphp | 6 ++++- tests/acceptance/acceptance/Finder.feature | 23 +++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Stubs/common/Component/Finder/Finder.stubphp b/src/Stubs/common/Component/Finder/Finder.stubphp index e182c0a..9c7f075 100644 --- a/src/Stubs/common/Component/Finder/Finder.stubphp +++ b/src/Stubs/common/Component/Finder/Finder.stubphp @@ -6,8 +6,12 @@ use Countable; use IteratorAggregate; /** - * @implements IteratorAggregate + * @implements IteratorAggregate */ class Finder implements IteratorAggregate, Countable { + /** + * @return \Iterator + */ + public function getIterator() {} } diff --git a/tests/acceptance/acceptance/Finder.feature b/tests/acceptance/acceptance/Finder.feature index f8ab205..08af8a7 100644 --- a/tests/acceptance/acceptance/Finder.feature +++ b/tests/acceptance/acceptance/Finder.feature @@ -4,26 +4,25 @@ Feature: Finder Background: Given I have Symfony plugin enabled - Scenario: Finder should be considered as an IteratorAggregate of SplFileInfo + Scenario: Finder is an IteratorAggregate with non-empty-string key and SplFileInfo value Given I have the following code """ $files - */ - public static function run(iterable $files): void - { + foreach ($finder as $key => $file) { + /** @psalm-trace $key */ + echo $key; + /** @psalm-trace $file */ } } - - $finder = new Finder(); - Test::run($finder); """ When I run Psalm - Then I see no errors + Then I see these errors + | Type | Message | + | Trace | $key: non-empty-string | + | Trace | $file: Symfony\Component\Finder\SplFileInfo | + And I see no other errors