diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index b8d863af50..acc9a3e6c0 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1108,11 +1108,13 @@ class Process * * This content will be passed to the underlying process standard input. * - * @param string|null $input The content + * @param mixed $input The content * * @return self The current Process instance * * @throws LogicException In case the process is running + * + * Passing an object as an input is deprecated since version 2.5 and will be removed in 3.0. */ public function setInput($input) { diff --git a/src/Symfony/Component/Process/ProcessBuilder.php b/src/Symfony/Component/Process/ProcessBuilder.php index 189ab8a3d1..1e3833774e 100644 --- a/src/Symfony/Component/Process/ProcessBuilder.php +++ b/src/Symfony/Component/Process/ProcessBuilder.php @@ -167,13 +167,13 @@ 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 + * @param mixed $input The input as a string * * @return ProcessBuilder * * @throws InvalidArgumentException In case the argument is invalid + * + * Passing an object as an input is deprecated since version 2.5 and will be removed in 3.0. */ public function setInput($input) { diff --git a/src/Symfony/Component/Process/ProcessUtils.php b/src/Symfony/Component/Process/ProcessUtils.php index 0f4cb89e6b..dd0a74373c 100644 --- a/src/Symfony/Component/Process/ProcessUtils.php +++ b/src/Symfony/Component/Process/ProcessUtils.php @@ -83,6 +83,8 @@ class ProcessUtils * @return string The validated input * * @throws InvalidArgumentException In case the input is not valid + * + * Passing an object as an input is deprecated since version 2.5 and will be removed in 3.0. */ public static function validateInput($caller, $input) { @@ -95,6 +97,8 @@ class ProcessUtils } // deprecated as of Symfony 2.5, to be removed in 3.0 if (is_object($input) && method_exists($input, '__toString')) { + trigger_error('Passing an object as an input is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); + return (string) $input; } diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 5bfd1a8692..345ae221c9 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -229,7 +229,24 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase array(null, null), array('24.5', 24.5), array('input data', 'input data'), - // to maintain BC, supposed to be removed in 3.0 + ); + } + + /** + * @dataProvider provideLegacyInputValues + */ + public function testLegacyValidInput($expected, $value) + { + $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); + + $process = $this->getProcess('php -v'); + $process->setInput($value); + $this->assertSame($expected, $process->getInput()); + } + + public function provideLegacyInputValues() + { + return array( array('stringifiable', new Stringifiable()), ); }