-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Process] Deprecate Process::setStdin in favor of Process::setInput #10932
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ class Process | |
private $commandline; | ||
private $cwd; | ||
private $env; | ||
private $stdin; | ||
private $input; | ||
private $starttime; | ||
private $lastOutputTime; | ||
private $timeout; | ||
|
@@ -128,15 +128,15 @@ class Process | |
* @param string $commandline The command line to run | ||
* @param string|null $cwd The working directory or null to use the working dir of the current PHP process | ||
* @param array|null $env The environment variables or null to inherit | ||
* @param string|null $stdin The STDIN content | ||
* @param string|null $input The input | ||
* @param int|float|null $timeout The timeout in seconds or null to disable | ||
* @param array $options An array of options for proc_open | ||
* | ||
* @throws RuntimeException When proc_open is not installed | ||
* | ||
* @api | ||
*/ | ||
public function __construct($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) | ||
public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array()) | ||
{ | ||
if (!function_exists('proc_open')) { | ||
throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.'); | ||
|
@@ -156,7 +156,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin | |
$this->setEnv($env); | ||
} | ||
|
||
$this->stdin = $stdin; | ||
$this->input = $input; | ||
$this->setTimeout($timeout); | ||
$this->useFileHandles = defined('PHP_WINDOWS_VERSION_BUILD'); | ||
$this->pty = false; | ||
|
@@ -224,7 +224,7 @@ public function mustRun($callback = null) | |
} | ||
|
||
/** | ||
* Starts the process and returns after sending the STDIN. | ||
* Starts the process and returns after writing the input to STDIN. | ||
* | ||
* This method blocks until all STDIN data is sent to the process then it | ||
* returns while the process runs in the background. | ||
|
@@ -288,7 +288,7 @@ public function start($callback = null) | |
return; | ||
} | ||
|
||
$this->processPipes->write(false, $this->stdin); | ||
$this->processPipes->write(false, $this->input); | ||
$this->updateStatus(false); | ||
$this->checkTimeout(); | ||
} | ||
|
@@ -1038,10 +1038,23 @@ public function setEnv(array $env) | |
* Gets the contents of STDIN. | ||
* | ||
* @return string|null The current contents | ||
* | ||
* @deprecated Deprecated since version 2.5, to be removed in 3.0. | ||
* This method is deprecated in favor of getInput. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we throw a deprecated error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope. We will only add the deprecation warning in the last minor version of Symfony before 3.0, like everywhere else |
||
public function getStdin() | ||
{ | ||
return $this->stdin; | ||
return $this->getInput(); | ||
} | ||
|
||
/** | ||
* Gets the Process input. | ||
* | ||
* @return null|string The Process input | ||
*/ | ||
public function getInput() | ||
{ | ||
return $this->input; | ||
} | ||
|
||
/** | ||
|
@@ -1052,14 +1065,33 @@ public function getStdin() | |
* @return self The current Process instance | ||
* | ||
* @throws LogicException In case the process is running | ||
* | ||
* @deprecated Deprecated since version 2.5, to be removed in 3.0. | ||
* This method is deprecated in favor of setInput. | ||
*/ | ||
public function setStdin($stdin) | ||
{ | ||
return $this->setInput($stdin); | ||
} | ||
|
||
/** | ||
* Sets the input. | ||
* | ||
* This content will be passed to the underlying process standard input. | ||
* | ||
* @param string|null $input The content | ||
* | ||
* @return self The current Process instance | ||
* | ||
* @throws LogicException In case the process is running | ||
*/ | ||
public function setInput($input) | ||
{ | ||
if ($this->isRunning()) { | ||
throw new LogicException('STDIN can not be set while the process is running.'); | ||
throw new LogicException('Input can not be set while the process is running.'); | ||
} | ||
|
||
$this->stdin = $stdin; | ||
$this->input = $input; | ||
|
||
return $this; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not always write to stdin anymore, does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an input is passed, yes it's written to the underlying process's stdin.