diff --git a/src/Monolog/Handler/ProcessHandler.php b/src/Monolog/Handler/ProcessHandler.php index 8101aa79..3cdda13a 100644 --- a/src/Monolog/Handler/ProcessHandler.php +++ b/src/Monolog/Handler/ProcessHandler.php @@ -67,8 +67,12 @@ class ProcessHandler extends AbstractProcessingHandler */ public function __construct($command, $level = Logger::DEBUG, $bubble = true, $cwd = null) { - $this->guardAgainstInvalidCommand($command); - $this->guardAgainstInvalidCwd($cwd); + if (empty($command) || is_string($command) === false) { + throw new \InvalidArgumentException('The command argument must be a non-empty string.'); + } + if ($cwd !== null && (empty($cwd) || is_string($cwd) === false)) { + throw new \InvalidArgumentException('The optional CWD argument must be a non-empty string, if any.'); + } parent::__construct($level, $bubble); @@ -76,30 +80,6 @@ class ProcessHandler extends AbstractProcessingHandler $this->cwd = $cwd; } - /** - * @param string $command - * @throws \InvalidArgumentException - * @return void - */ - private function guardAgainstInvalidCommand($command) - { - if (empty($command) || is_string($command) === false) { - throw new \InvalidArgumentException('The command argument must be a non-empty string.'); - } - } - - /** - * @param string $cwd - * @throws \InvalidArgumentException - * @return void - */ - private function guardAgainstInvalidCwd($cwd) - { - if ($cwd !== null && (empty($cwd) || is_string($cwd) === false)) { - throw new \InvalidArgumentException('The optional CWD argument must be a non-empty string, if any.'); - } - } - /** * Writes the record down to the log of the implementing handler * @@ -156,7 +136,6 @@ class ProcessHandler extends AbstractProcessingHandler */ private function handleStartupErrors() { - $selected = $this->selectErrorStream(); if (false === $selected) { throw new \UnexpectedValueException('Something went wrong while selecting a stream.'); @@ -180,6 +159,7 @@ class ProcessHandler extends AbstractProcessingHandler { $empty = []; $errorPipes = [$this->pipes[2]]; + return stream_select($errorPipes, $empty, $empty, 1); } @@ -203,7 +183,7 @@ class ProcessHandler extends AbstractProcessingHandler */ protected function writeProcessInput($string) { - fwrite($this->pipes[0], (string)$string); + fwrite($this->pipes[0], (string) $string); } /** @@ -216,7 +196,7 @@ class ProcessHandler extends AbstractProcessingHandler fclose($pipe); } proc_close($this->process); + $this->process = null; } - $this->process = null; } } diff --git a/tests/Monolog/Handler/ProcessHandlerTest.php b/tests/Monolog/Handler/ProcessHandlerTest.php index fbee3c50..d2d62f1a 100644 --- a/tests/Monolog/Handler/ProcessHandlerTest.php +++ b/tests/Monolog/Handler/ProcessHandlerTest.php @@ -11,7 +11,7 @@ namespace Monolog\Handler; -use Monolog\TestCase; +use Monolog\Test\TestCase; use Monolog\Logger; class ProcessHandlerTest extends TestCase