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

This commit is contained in:
Romain Neutron 2014-05-17 19:36:35 +02:00
parent e7971e5af5
commit 9887b831d2
5 changed files with 12 additions and 2 deletions

View File

@ -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.

View File

@ -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
-----

View File

@ -1060,6 +1060,8 @@ class Process
/**
* 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

View File

@ -156,6 +156,8 @@ class ProcessBuilder
/**
* 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

View File

@ -75,7 +75,7 @@ class ProcessUtils
}
/**
* 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
@ -87,7 +87,11 @@ class ProcessUtils
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;
}