Fixed Finder key and value (#221)

This commit is contained in:
Valentin Udaltsov 2021-10-14 07:46:04 +03:00 committed by GitHub
parent de574cc9f2
commit 0831a0160c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 13 deletions

View File

@ -6,8 +6,12 @@ use Countable;
use IteratorAggregate; use IteratorAggregate;
/** /**
* @implements IteratorAggregate<string, SplFileInfo> * @implements IteratorAggregate<non-empty-string, SplFileInfo>
*/ */
class Finder implements IteratorAggregate, Countable class Finder implements IteratorAggregate, Countable
{ {
/**
* @return \Iterator<non-empty-string, SplFileInfo>
*/
public function getIterator() {}
} }

View File

@ -4,26 +4,25 @@ Feature: Finder
Background: Background:
Given I have Symfony plugin enabled 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 Given I have the following code
""" """
<?php <?php
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
class Test function run(Finder $finder): void
{
/**
* @param iterable<SplFileInfo> $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 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