Thanks to visit codestin.com
Credit goes to github.com

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADE-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions src/Symfony/Component/Process/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
* added the convenience method "mustRun"
* deprecation: Process::setStdin() is deprecated in favor of Process::setInput()
* deprecation: Process::getStdin() is deprecated in favor of Process::getInput()
* deprecation: Process::setInput() and ProcessBuilder::setInput() do not accept non-scalar types

2.4.0
-----
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,8 @@ public function getInput()
/**
* Sets the contents of STDIN.
*
* Deprecation: As of Symfony 2.5, this method only accepts scalar values.
*
* @param string|null $stdin The new contents
*
* @return self The current Process instance
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Process/ProcessBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ public function addEnvironmentVariables(array $variables)
/**
* Sets the input of the process.
*
* Deprecation: As of Symfony 2.5, this method only accepts string values.
*
* @param string|null $input The input as a string
*
* @return ProcessBuilder
Expand Down
8 changes: 6 additions & 2 deletions src/Symfony/Component/Process/ProcessUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static function escapeArgument($argument)
}

/**
* Validates and normalized a Process input
* Validates and normalizes a Process input
*
* @param string $caller The name of method call that validates the input
* @param mixed $input The input to validate
Expand All @@ -87,7 +87,11 @@ 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_scalar($input)) {
return (string) $input;
}
// deprecated as of Symfony 2.5, to be removed in 3.0
if (is_object($input) && method_exists($input, '__toString')) {
return (string) $input;
}

Expand Down