-
Notifications
You must be signed in to change notification settings - Fork 3.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
dataAvailable method backported to 2.4 #1098
Conversation
*/ | ||
public function dataAvailable($timeout = 0) { | ||
$readFds = array($this->_input); | ||
$readyFds = stream_select($readFds, $w = null, $e = null, $timeout); |
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.
Inline assignments in function calls always look like a mistake. You should assign these variables above the function call and pass them in.
@markstory See pull request #1020 ;-) |
I don't think the initialization is even necessary. A (small) flaw in PHP itself one could say. |
Well I made a mistake last time, these things happen. I'll fix the code in |
I think it the initialization is necessary because these parameters are also a input to this function, by passing uninitialized variables you don't actually know what happens and PHP throws a warning. From: http://php.net/manual/en/function.stream-select.php e.g. write: 'The streams listed in the write array will be watched to see if a write will not block.' which means that (even though its a reference) it still is input. |
Interesting, I only know if from exec() etc where you don't need to do that. But maybe this method behaves differently. |
Based on my local testing, this method like most of the gross C API's in PHP don't need the variables initialized. <?php
error_reporting(-1);
$fds = array(fopen('php://stdin', 'r'));
$ready = stream_select($fds, $write, $error, 0); Works fine on my machine without any notice errors. |
I still don't like it, when the PHP interpreter changes this may give problems, just relying on the default of the interpreter is not the best way to go in my opinion. |
This behavior is quite unlikely to ever change :) |
@dereuromark, Yeah I think your right. Still I think its better to init imo. BUT now we saved 2 lines of code! |
You still need to squash, though. |
@dereuromark what do you mean? |
those 5 commits should be merged into a single one by rebasing it upstream and squashing them into a single commit. |
@markstory except that phpcs will complain about Unused variable. |
@ceeram That's a separate problem, I can take care of that after the merge. |
* '2.4' of github.com:djbobke/cakephp: Remove variable initialization
See #1112 :) |
See #1112 |
I already did this for 3.0 earlier, now for 2.4