-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Finder] Fix SplFileInfo PHPDoc #45725
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Hey! I think @julienfalque has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
@@ -26,8 +26,8 @@ class FileTypeFilterIterator extends \FilterIterator | |||
private int $mode; | |||
|
|||
/** | |||
* @param \Iterator $iterator The Iterator to filter | |||
* @param int $mode The mode (self::ONLY_FILES or self::ONLY_DIRECTORIES) | |||
* @param \Iterator<string, \SplFileInfo> $iterator The Iterator to filter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also require our SplFileInfo
implementation here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the question is what we want to achieve here. We have no real control over who is using these iterators besides the Finder implementation itself. Any changes we make here could be perceived as introducing new "bugs" by people who use the iterators in a legitimate/compatible way. Personally, I'm clearly aiming at bug fixes without such potentially controversial side-effects here.
More detailed explanation:
- RecursiveDirectoryIterator::current returns Symfony SplFileInfo, so that's its Iterator value type.
- RecursiveDirectoryIterator is the starting point base iterator in Finder::searchInDirectory, hence the whole Finder iterator chain iterates over Symfony SplFileInfo, too.
So from a strictly internal point of view, all of the iterators use the Symfony SplFileInfo.
To determine which type of SplFileInfo class each iterator can use we need to look at the current() method and its calls/usages. Basically there are three cases here:
- If the current() method is implemented explicitly and returns the Symfony SplFileInfo, that's the Iterator value type. Example: RecursiveDirectoryIterator
- Usages that access one of the relative path methods require a Symfony SplFileInfo so the corresponding iterator needs to provide that. Example: PathFilterIterator
- Usages that only access methods of \SplFileInfo can work with any iterator that provides \SplFileInfo or any subclass of it. Example: FileTypeFilterIterator
Thank you @InvisibleSmiley. |
Not sure how to test this, maybe you do.