-
Notifications
You must be signed in to change notification settings - Fork 8
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
https
streams on Ubuntu 22.04 might emit PHP warnings during fread()
#504
Comments
Hmm, that's unfortunate.
Throwing something that extends Error or RuntimeException is not a violation of a contact. I always take the view those those type of throwables are always fair game to be thrown at any time, just like with Java. |
Don't want to nitpick here more than necessary, but For RuntimeException I generally agree, but the cause of the warning in this case matches Java's IOException / EOFException more closely and that one is a checked exception in Java I believe. Generally speaking the PHP Warning can be triggered by the remote server at will and thus it is unfixable by the user of the psr7 implementation, other than by catching |
might be an acceptable fix as well. This ensures that any exception is then rewrapped as a
|
Yeh, that would be a good solution. |
Resolved with #505 |
PHP version: 8.1.2
Description
Because of php/php-src#8369 a
https
stream might emit a Warning when callingfread()
on the underlying stream. If a user of PSR-7 uses an error handler that converts warnings into Exceptions then the call to->read()
might violateread()
's contract to throw aRuntimeException
is cases of failure.How to reproduce
Possible Solution
The call to
fread()
:psr7/src/Stream.php
Line 232 in 58a607d
can be prefixed with
@
to fix this issue. Note thatfread()
won't returnfalse
for this warning.. Alternatively a custom error handler might be attached before the call and detached afterwards.Additional context
The text was updated successfully, but these errors were encountered: