Skip to content

[Process] Add InputStream to seamlessly feed running processes #18386

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

Merged
merged 1 commit into from
Apr 2, 2016

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #18262
License MIT
Doc PR symfony/symfony-docs#6424

Look at the tests, beautiful, isn't it?


public function __construct(callable $onEmpty = null)
{
$this->onEmpty($onEmpty);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why calling method instead of directly the variable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the class could be extended

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact, I removed the constructor

@nicolas-grekas nicolas-grekas force-pushed the proc-input-stream branch 2 times, most recently from 87cc4f8 to 547862c Compare March 31, 2016 16:31
}

/**
* Tells is write buffer is closed or not.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tells whether

@nicolas-grekas
Copy link
Member Author

comments addressed

@Cydonia7
Copy link
Contributor

Cydonia7 commented Apr 1, 2016

This looks awesome and the implementation is quite elegant, I hope this will be merged soon!

@romainneutron
Copy link
Contributor

👍 However, it definitely needs a documentation PR associated

@nicolas-grekas
Copy link
Member Author

@romainneutron doc PR linked

}

/**
* Appends an input to the write buffer.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing phpdoc for the argument type

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!is_scalar($input)) {
throw new InvalidArgumentException(sprintf('%s yielded a value of type "%s", but only scalars and stream resources are supported', get_class($this->input), gettype($input)));
}
$input = (string) $input;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too familiar with streams, but the exception makes me believe that a stream will be casted to a string here.

$ php -r '$f = fopen("composer.json", "r"); echo (string) $f;'
Resource id #5

Is this what it's intended to to or am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're missing #18386 (diff)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, that explains the "resource" part of the exception, gotcha!

@fabpot
Copy link
Member

fabpot commented Apr 2, 2016

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 3d20b6c into symfony:master Apr 2, 2016
fabpot added a commit that referenced this pull request Apr 2, 2016
…rocesses (nicolas-grekas)

This PR was merged into the 3.1-dev branch.

Discussion
----------

[Process] Add InputStream to seamlessly feed running processes

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #18262
| License       | MIT
| Doc PR        | symfony/symfony-docs#6424

Look at the tests, beautiful, isn't it?

Commits
-------

3d20b6c [Process] Add InputStream to seamlessly feed running processes
@nicolas-grekas nicolas-grekas deleted the proc-input-stream branch April 2, 2016 08:47
fabpot added a commit that referenced this pull request Apr 3, 2016
… (nicolas-grekas)

This PR was merged into the 3.1-dev branch.

Discussion
----------

[Process] Implement IteratorAggregate to stream output

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | symfony/symfony-docs#6424

Sibling to #18386 for iterating of the output streams.

Commits
-------

5947f5d [Process] Implement IteratorAggregate to stream output
@fabpot fabpot mentioned this pull request May 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants