mirror of
https://github.com/danog/psalm-plugin-symfony.git
synced 2024-11-30 04:29:10 +01:00
Fixed Finder key and value (#221)
This commit is contained in:
parent
de574cc9f2
commit
0831a0160c
@ -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() {}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user