-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix GH-9883 SplFileObject::__toString() reads next line #9912
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
Conversation
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.
Looks good to me
The documentation of __toString() will need to be changed as well
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.
Thank you!
I'm not sure if it makes any sense to target PHP-8.0; there may be no further regular bug fix release. But even if, it might be too risky that late in the release cycle (especially given that the bug is there for years). |
Should I change the branch to 8.1 then? or also leave 8.1 alone and only target 8.2? |
Depends on how certain we can be that this doesn't break existing code. I tend to think that it's good for 8.1. |
We need to overwrite the __toString magic method for SplFileObject, similarly to how DirectoryIterator overwrites it Moreover, the custom cast handler is useless as we define __toString methods, so use the standard one instead.
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.
Thank you!
<?php | ||
$file_stream = new SplFileObject(__FILE__, 'rb'); | ||
|
||
echo $file_stream; // line 4 |
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.
Why such comments? I would remove them.
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.
See #9883. The comments helped to identify what was going on, and may be helpful if something breaks (again) in the future.
We need to overwrite the __toString magic method for SplFileObject, similarly to how DirectoryIterator overwrites it Moreover, the custom cast handler is useless as we define __toString methods, so use the standard one instead.