8000 minor #13600 [Process] added a deprecation notice (fabpot) · symfony/symfony@9509fb7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9509fb7

Browse files
committed
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
2 parents 0d4ed2b + a901ca2 commit 9509fb7

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,11 +1108,13 @@ public function setStdin($stdin)
11081108
*
11091109
* This content will be passed to the underlying process standard input.
11101110
*
1111-
* @param string|null $input The content
1111+
* @param mixed $input The content
11121112
*
11131113
* @return self The current Process instance
11141114
*
11151115
* @throws LogicException In case the process is running
1116+
*
1117+
* Passing an object as an input is deprecated since version 2.5 and will be removed in 3.0.
11161118
*/
11171119
public function setInput($input)
11181120
{

src/Symfony/Component/Process/ProcessBuilder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,13 @@ public function addEnvironmentVariables(array $variables)
167167
/**
168168
* Sets the input of the process.
169169
*
170-
* @param string|null $input The input as a string
170+
* @param mixed $input The input as a string
171171
*
172172
* @return ProcessBuilder
173173
*
174174
* @throws InvalidArgumentException In case the argument is invalid
175+
*
176+
* Passing an object as an input is deprecated since version 2.5 and will be removed in 3.0.
175177
*/
176178
public function setInput($input)
177179
{

src/Symfony/Component/Process/ProcessUtils.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public static function escapeArgument($argument)
8383
* @return string The validated input
8484
*
8585
* @throws InvalidArgumentException In case the input is not valid
86+
*
87+
* Passing an object as an input is deprecated since version 2.5 and will be removed in 3.0.
8688
*/
8789
public static function validateInput($caller, $input)
8890
{
@@ -95,6 +97,8 @@ public static function validateInput($caller, $input)
9597
}
9698
// deprecated as of Symfony 2.5, to be removed in 3.0
9799
if (is_object($input) && method_exists($input, '__toString')) {
100+
trigger_error('Passing an object as an input is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
101+
98102
return (string) $input;
99103
}
100104

src/Symfony/Component/Process/Tests/AbstractProcessTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,24 @@ public function provideInputValues()
229229
array(null, null),
230230
array('24.5', 24.5),
231231
array('input data', 'input data'),
232-
// to maintain BC, supposed to be removed in 3.0
232+
);
233+
}
234+
235+
/**
236+
* @dataProvider provideLegacyInputValues
237+
*/
238+
public function testLegacyValidInput($expected, $value)
239+
{
240+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
241+
242+
$process = $this->getProcess('php -v');
243+
$process->setInput($value);
244+
$this->assertSame($expected, $process->getInput());
245+
}
246+
247+
public function provideLegacyInputValues()
248+
{
249+
return array(
233250
array('stringifiable', new Stringifiable()),
234251
);
235252
}

0 commit comments

Comments
 (0)
0