-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Process] Accept Traversable input #18350
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
nicolas-grekas
commented
Mar 29, 2016
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #18262 |
License | MIT |
Doc PR | - |
4fb43fb
to
c6485ee
Compare
|
||
throw new InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller)); | ||
throw new InvalidArgumentException(sprintf('%s only accepts strings, Traversable objects or stream resources.', $caller)); |
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.
technically, your code won't accept Traversable implemented in C without implementing Iterator, or implemented in PHP with IteratorAggregate returning such a traversable.
you should use IteratorIterator
instead to wrap any Traversable into an Iterator.
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.
8a72e3d
to
5245bed
Compare
{ | ||
$input = function ($data) { | ||
while (false !== $data) { | ||
$data = (yield $data); |
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.
HHVM doesn't seem to be happy with yield
.
5245bed
to
b3f382b
Compare
HHVM test fixed |
b3f382b
to
b9782b7
Compare
Sounds very good ! Good job! |
} | ||
} | ||
} | ||
|
||
// no input to read on resource, buffer is empty | ||
if (null === $this->input && !isset($this->inputBuffer[0])) { | ||
if (!isset($this->inputBuffer[0]) && !($this->input instanceof \Iterator ? $this->input->valid() : $this->input)) { |
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 do we use isset()
to test for the empty string instead of comparing it with the empty string like we usually do?
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.
because false
is also a possible value here
👍 LGTM |
Thank you @nicolas-grekas. |
This PR was merged into the 3.1-dev branch. Discussion ---------- [Process] Accept Traversable input | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #18262 | License | MIT | Doc PR | - Commits ------- b9782b7 [Process] Accept Traversable input