Return type of RecursiveDirectoryIterator::getChildren()
is too wide
#42468
Labels
RecursiveDirectoryIterator::getChildren()
is too wide
#42468
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 classRecursiveDirectoryIterator
. The core class declares the following return type: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 ofRecursiveDirectoryIterator
.The text was updated successfully, but these errors were encountered: