-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Closed
Copy link
Labels
Description
Symfony version(s) affected
6.0.0
Description
During one of the Merge branch '5.4' into 6.0 the PHPDoc return annotation (@return \Iterator<SplFileInfo>
) got removed from Symfony\Component\Finder\Finder::getIterator
method.
It results with static analysis tools such as Psalm falsely reporting issue:
ERROR: MixedAssignment - [path] - Unable to determine the type that $fileInfo is being assigned to (see https://psalm.dev/032)
foreach ($finder as $fileInfo) {
(where $finder
is obviously instance of Symfony\Component\Finder\Finder
)
How to reproduce
Run Psalm with totally typed mode on code iterating on Finder
's object.
Or, take a look here: https://github.com/kubawerlos/php-cs-fixer-custom-fixers/pull/714/commits
- 1st commit simply adds
symfony/finder:5.4.0
for Git to track - nothing special, CI still green - 2nd commit is upgrading to
symfony/finder:6.0.0
(it's removing constraint incomposer.json
, seecomposer.lock
to confirm), where PHPDoc return annotation forgetIterator
method is gone - CI is failing with Psalm's analysis - 3rd commit is adding only that annotation back to prove it is the reason of failing CI
Possible Solution
- restore removed annotation
Finder
class has in PHPDoc@implements \IteratorAggregate<string, SplFileInfo>
, so maybe Psalm is to update, not PHPdoc forgetIterator
(although for me it looks like the annotation was removed unintentionally)
Additional Context
@derrabus do you remember it removing that annotation was intentional?