mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-23 01:26:11 +02:00
Add some return type hints and fix up HandlerWrapper
This commit is contained in:
@@ -28,7 +28,7 @@ use Monolog\Formatter\FormatterInterface;
|
||||
*
|
||||
* @author Alexey Karapetov <alexey@karapetov.com>
|
||||
*/
|
||||
class HandlerWrapper implements HandlerInterface
|
||||
class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, FormattableHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var HandlerInterface
|
||||
@@ -47,7 +47,7 @@ class HandlerWrapper implements HandlerInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isHandling(array $record)
|
||||
public function isHandling(array $record): bool
|
||||
{
|
||||
return $this->handler->isHandling($record);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class HandlerWrapper implements HandlerInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(array $record)
|
||||
public function handle(array $record): bool
|
||||
{
|
||||
return $this->handler->handle($record);
|
||||
}
|
||||
@@ -71,34 +71,58 @@ class HandlerWrapper implements HandlerInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pushProcessor($callback)
|
||||
public function close()
|
||||
{
|
||||
$this->handler->pushProcessor($callback);
|
||||
return $this;
|
||||
return $this->handler->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function popProcessor()
|
||||
public function pushProcessor(callable $callback): HandlerInterface
|
||||
{
|
||||
return $this->handler->popProcessor();
|
||||
if ($this->handler instanceof ProcessableHandlerInterface) {
|
||||
$this->handler->pushProcessor($callback);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
throw new \LogicException('The wrapped handler does not implement ' . ProcessableHandlerInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setFormatter(FormatterInterface $formatter)
|
||||
public function popProcessor(): callable
|
||||
{
|
||||
$this->handler->setFormatter($formatter);
|
||||
return $this;
|
||||
if ($this->handler instanceof ProcessableHandlerInterface) {
|
||||
return $this->handler->popProcessor();
|
||||
}
|
||||
|
||||
throw new \LogicException('The wrapped handler does not implement ' . ProcessableHandlerInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormatter()
|
||||
public function setFormatter(FormatterInterface $formatter): HandlerInterface
|
||||
{
|
||||
return $this->handler->getFormatter();
|
||||
if ($this->handler instanceof FormattableHandlerInterface) {
|
||||
$this->handler->setFormatter($formatter);
|
||||
}
|
||||
|
||||
throw new \LogicException('The wrapped handler does not implement ' . FormattableHandlerInterface::class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormatter(): FormatterInterface
|
||||
{
|
||||
if ($this->handler instanceof FormattableHandlerInterface) {
|
||||
return $this->handler->getFormatter($formatter);
|
||||
}
|
||||
|
||||
throw new \LogicException('The wrapped handler does not implement ' . FormattableHandlerInterface::class);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user