1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-04 12:17:35 +02:00

Fix more instances of bad FormattableHandlerInterface usages

This commit is contained in:
Jordi Boggiano
2020-12-11 13:11:35 +01:00
parent 1d5456ec07
commit 61e5ff2b36
3 changed files with 17 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
{
use ProcessableHandlerTrait;
/** @var HandlerInterface */
protected $handler;
protected $bufferSize = 0;
protected $bufferLimit;
@@ -137,16 +138,24 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
*/
public function setFormatter(FormatterInterface $formatter): HandlerInterface
{
if ($this->handler instanceof FormattableHandlerInterface) {
$this->handler->setFormatter($formatter);
return $this;
}
throw new \UnexpectedValueException('The nested handler of type '.get_class($this->handler).' does not support formatters.');
}
/**
* {@inheritdoc}
*/
public function getFormatter(): FormatterInterface
{
if ($this->handler instanceof FormattableHandlerInterface) {
return $this->handler->getFormatter();
}
throw new \UnexpectedValueException('The nested handler of type '.get_class($this->handler).' does not support formatters.');
}
}

View File

@@ -37,6 +37,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
{
use ProcessableHandlerTrait;
/** @var HandlerInterface */
protected $handler;
protected $activationStrategy;
protected $buffering = true;

View File

@@ -23,6 +23,7 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface, Reset
{
use ProcessableHandlerTrait;
/** @var HandlerInterface[] */
protected $handlers;
protected $bubble;
@@ -116,8 +117,10 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface, Reset
public function setFormatter(FormatterInterface $formatter): HandlerInterface
{
foreach ($this->handlers as $handler) {
if ($handler instanceof FormattableHandlerInterface) {
$handler->setFormatter($formatter);
}
}
return $this;
}