-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
gh-1838 added checks for pipe streams #1872
Conversation
Since Slim's implementation has methods beyond what's in StreamInterface anyway, I'd add isSeekableForward() and seekForward() for completeness. If one's dealing with pipes, he/she might need them anyway.
I'd also change isSeekable() implementation - there's no need for isPipe() call, I think, as 'seekable' metadata is guaranteed to be 1 in case of seekable handle and something else (typically 0 but undef for pipes) in other cases.
HTH. |
Thanks for the feedback, @ddalek. I replaced |
Argh, I misinterpreted print_r() output. My comparison was unnecessary, the value returned is bool, not int. This will teach me not to rely on print_r(). :) Still, 'seekable' meta should be false for pipes (despite SEEK_CUR working) and |
For some reason the tests fail on the hhvm machine: |
I removed the check for |
Cursory search through their issues shows quite a few historical incompatibilities around files and streams, including a new one around fseek() so I'm not terribly surprised. I'll take the time over the weekend to see if there's anything that can and should be done in Slim or if it's HHVM problem. |
Tests fail on HHVM. |
@i created a virtual machine with hhvm and could reproduce the failing tests. The cause was I removed the seekForward implementation for now, as it doesn't seem to work for pipes in PHP. Update: the reason <?php
$fh = popen('echo 1', 'r');
$meta = stream_get_meta_data($fh);
var_dump($meta['mode']);
stream_get_contents($fh);
pclose($fh); Result using PHP (version 7.0.4): Apparently, the mode for the stream cannot be determined using Also, although the metadata provided by hhvm using With the current behaviour of hhvm, I think it will be hard to get pipes supported by Update: I have reported the issue at hhvm: facebook/hhvm#7089 |
* | ||
* @var type | ||
*/ | ||
protected $pipe; |
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.
Please name this property isPipe
.
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.
That would collide with the isPipe
method
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.
No. PHP can tell the difference between a property and a method with the same name…
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.
I didn't know that :)
Fixes #1838