Skip to content

Commit

Permalink
[Process] Deprecate using values that are not string for Process::set…
Browse files Browse the repository at this point in the history
…Stdin and ProcessBuilder::setInput
  • Loading branch information
romainneutron committed May 23, 2014
1 parent 5c35bcf commit 5d7d78e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions 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 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 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 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

0 comments on commit 5d7d78e

Please sign in to comment.