Description
Symfony version(s) affected: 5.3
Description
PHP 8.1 adds tentative return types and triggers deprecation warnings if the return types of our implementations are missing or incompatible. We can add a ReturnTypeWillChange
attribute to suppress the deprecation, but we should eventually remove it and replace it with an actual return type. This is what PR #42378 does.
Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator
overrides the core class RecursiveDirectoryIterator
. The core class declares the following return type:
public function getChildren(): \RecursiveDirectoryIterator
This is a problem because our implementation under certain circumstances returns RecursiveArrayIterator
because of that, the return type that we would need to declare would not be covariant to the return type of the core function.
How to reproduce
https://github.com/symfony/symfony/runs/3293455759?check_suite_focus=true#step:8:191
Possible Solution
Change the implementation of getChildren()
so that it always returns instances of RecursiveDirectoryIterator
.