10000 [Process] added a deprecation notice by fabpot · Pull Request #13600 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Process] added a deprecation notice #13600

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
Feb 11, 2015
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
10000
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -1108,11 +1108,13 @@ public function setStdin($stdin)
*
* 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)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Process/ProcessBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ 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
* @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)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Process/ProcessUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public static function escapeArgument($argument)
* @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)
{
Expand All @@ -95,6 +97,8 @@ public static function validateInput($caller, $input)
}
// 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;
}

Expand Down
19 changes: 18 additions & 1 deletion src/Symfony/Component/Process/Tests/AbstractProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,24 @@ public function provideInputValues()
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()),
);
}
Expand Down
0