1
0
mirror of https://github.com/danog/process.git synced 2025-01-22 22:01:22 +01:00

Fix preconditions for getStdin / getStdout / getStderr

This commit is contained in:
Niklas Keller 2017-09-19 16:16:48 +02:00 committed by Aaron Piotrowski
parent 7cf91efd08
commit 8f9d1d234a
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB

View File

@ -211,6 +211,10 @@ class Process {
* @return ProcessOutputStream * @return ProcessOutputStream
*/ */
public function getStdin(): ProcessOutputStream { public function getStdin(): ProcessOutputStream {
if (!$this->handle) {
throw new StatusError("The process has not been started");
}
return $this->handle->stdin; return $this->handle->stdin;
} }
@ -220,8 +224,8 @@ class Process {
* @return ProcessInputStream * @return ProcessInputStream
*/ */
public function getStdout(): ProcessInputStream { public function getStdout(): ProcessInputStream {
if (!$this->isRunning()) { if (!$this->handle) {
throw new StatusError("The process is not running"); throw new StatusError("The process has not been started");
} }
return $this->handle->stdout; return $this->handle->stdout;
@ -233,8 +237,8 @@ class Process {
* @return ProcessInputStream * @return ProcessInputStream
*/ */
public function getStderr(): ProcessInputStream { public function getStderr(): ProcessInputStream {
if (!$this->isRunning()) { if (!$this->handle) {
throw new StatusError("The process is not running"); throw new StatusError("The process has not been started");
} }
return $this->handle->stderr; return $this->handle->stderr;