Skip to content

[Process] Deprecate using values that are not string for Process::setStdin and ProcessBuilder::setInput #10930

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
May 23, 2014

Conversation

romainneutron
Copy link
Contributor

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets n/a
License MIT

This deprecates passing a Process input any value that is not a strict string. This needs #10929 to be merged.
I don't know if the use of trigger_error is correct or should be removed.

{
if (null !== $input && !is_string($input)) {
if (is_scalar($input) || (is_object($input) && method_exists($input, '__toString'))) {
trigger_error(sprintf('% only accepts stream resource and string as input.'), E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

stream resources are not accepted

Copy link
Member

Choose a reason for hiding this comment

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

and I would not forbid passing another scalar but just cast it when setting it. PHP does not have strict types for scalars

@romainneutron
Copy link
Contributor Author

PR rebased and updated, comments addressed.

@@ -971,3 +971,4 @@ UPGRADE FROM 2.x to 3.0

* Process::setStdin() and Process::getStdin() have been removed. Use
Process::setInput() and Process::getInput() that works the same way.
* Process::setInput and ProcessBuilder::setInput do not accept non-scalar types.
Copy link
Member

Choose a reason for hiding this comment

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

missing () at the end of the method name (same below).

@romainneutron
Copy link
Contributor Author

PR Updated, comments addressed

@@ -87,7 +87,12 @@ public static function escapeArgument($argument)
public static function validateInput($caller, $input)
{
if (null !== $input) {
if (is_scalar($input) || (is_object($input) && method_exists($input, '__toString'))) {
if (is_object($input) && method_exists($input, '__toString')) {
trigger_error(sprintf('% only accepts string as input.', $caller), E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

we don't trigger deprecation errors for stuff working until 3.0. We will only do it the last minor release before 3.0

@romainneutron
Copy link
Contributor Author

PR updated, @stof comments addressed

@fabpot fabpot merged commit 9887b83 into symfony:master May 23, 2014
fabpot added a commit that referenced this pull request May 23, 2014
…or Process::setStdin and ProcessBuilder::setInput (romainneutron)

This PR was merged into the 2.4-dev branch.

Discussion
----------

[Process] Deprecate using values that are not string for Process::setStdin and ProcessBuilder::setInput

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT

This deprecates passing a `Process` input any value that is not a strict string. This needs #10929 to be merged.
I don't know if the use of `trigger_error` is correct or should be removed.

Commits
-------

9887b83 [Process] Deprecate using values that are not string for Process::setStdin and ProcessBuilder::setInput
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants