minor #13600 [Process] added a deprecation notice (fabpot)

This PR was merged into the 2.7 branch.

Discussion
----------

[Process] added a deprecation notice

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #12703, #12725
| License       | MIT
| Doc PR        | n/a

Commits
-------

a901ca2 [Process] added a deprecation notice
This commit is contained in:
Fabien Potencier 2015-02-11 13:46:36 +01:00
commit 9509fb7f51
4 changed files with 28 additions and 3 deletions

View File

@ -1108,11 +1108,13 @@ class Process
* *
* This content will be passed to the underlying process standard input. * 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 * @return self The current Process instance
* *
* @throws LogicException In case the process is running * @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) public function setInput($input)
{ {

View File

@ -167,11 +167,13 @@ class ProcessBuilder
/** /**
* Sets the input of the process. * Sets the input of the process.
* *
* @param string|null $input The input as a string * @param mixed $input The input as a string
* *
* @return ProcessBuilder * @return ProcessBuilder
* *
* @throws InvalidArgumentException In case the argument is invalid * @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) public function setInput($input)
{ {

View File

@ -83,6 +83,8 @@ class ProcessUtils
* @return string The validated input * @return string The validated input
* *
* @throws InvalidArgumentException In case the input is not valid * @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) public static function validateInput($caller, $input)
{ {
@ -95,6 +97,8 @@ class ProcessUtils
} }
// deprecated as of Symfony 2.5, to be removed in 3.0 // deprecated as of Symfony 2.5, to be removed in 3.0
if (is_object($input) && method_exists($input, '__toString')) { 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; return (string) $input;
} }

View File

@ -229,7 +229,24 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
array(null, null), array(null, null),
array('24.5', 24.5), array('24.5', 24.5),
array('input data', 'input data'), 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()), array('stringifiable', new Stringifiable()),
); );
} }