mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-02 03:10:15 +02:00
Coding style fixes, refs #720
This commit is contained in:
@@ -67,8 +67,12 @@ class ProcessHandler extends AbstractProcessingHandler
|
|||||||
*/
|
*/
|
||||||
public function __construct($command, $level = Logger::DEBUG, $bubble = true, $cwd = null)
|
public function __construct($command, $level = Logger::DEBUG, $bubble = true, $cwd = null)
|
||||||
{
|
{
|
||||||
$this->guardAgainstInvalidCommand($command);
|
if (empty($command) || is_string($command) === false) {
|
||||||
$this->guardAgainstInvalidCwd($cwd);
|
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);
|
parent::__construct($level, $bubble);
|
||||||
|
|
||||||
@@ -76,30 +80,6 @@ class ProcessHandler extends AbstractProcessingHandler
|
|||||||
$this->cwd = $cwd;
|
$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
|
* Writes the record down to the log of the implementing handler
|
||||||
*
|
*
|
||||||
@@ -156,7 +136,6 @@ class ProcessHandler extends AbstractProcessingHandler
|
|||||||
*/
|
*/
|
||||||
private function handleStartupErrors()
|
private function handleStartupErrors()
|
||||||
{
|
{
|
||||||
|
|
||||||
$selected = $this->selectErrorStream();
|
$selected = $this->selectErrorStream();
|
||||||
if (false === $selected) {
|
if (false === $selected) {
|
||||||
throw new \UnexpectedValueException('Something went wrong while selecting a stream.');
|
throw new \UnexpectedValueException('Something went wrong while selecting a stream.');
|
||||||
@@ -180,6 +159,7 @@ class ProcessHandler extends AbstractProcessingHandler
|
|||||||
{
|
{
|
||||||
$empty = [];
|
$empty = [];
|
||||||
$errorPipes = [$this->pipes[2]];
|
$errorPipes = [$this->pipes[2]];
|
||||||
|
|
||||||
return stream_select($errorPipes, $empty, $empty, 1);
|
return stream_select($errorPipes, $empty, $empty, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +183,7 @@ class ProcessHandler extends AbstractProcessingHandler
|
|||||||
*/
|
*/
|
||||||
protected function writeProcessInput($string)
|
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);
|
fclose($pipe);
|
||||||
}
|
}
|
||||||
proc_close($this->process);
|
proc_close($this->process);
|
||||||
|
$this->process = null;
|
||||||
}
|
}
|
||||||
$this->process = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Monolog\Handler;
|
namespace Monolog\Handler;
|
||||||
|
|
||||||
use Monolog\TestCase;
|
use Monolog\Test\TestCase;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
|
|
||||||
class ProcessHandlerTest extends TestCase
|
class ProcessHandlerTest extends TestCase
|
||||||
|
Reference in New Issue
Block a user