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

Static analysis improvements (#1475)

* Static analysis improvements

* Fix review issues
This commit is contained in:
Mponos George
2020-07-08 22:40:29 +03:00
committed by GitHub
parent 84342aa0a3
commit 53e2c97b0b
8 changed files with 20 additions and 1 deletions

View File

@@ -49,6 +49,8 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
protected $bubble; protected $bubble;
/** /**
* @psalm-param HandlerInterface|callable(?array, HandlerInterface): HandlerInterface $handler
*
* @param callable|HandlerInterface $handler Handler or factory callable($record|null, $filterHandler). * @param callable|HandlerInterface $handler Handler or factory callable($record|null, $filterHandler).
* @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided * @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided
* @param int|string $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array * @param int|string $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array

View File

@@ -47,6 +47,8 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
protected $bubble; protected $bubble;
/** /**
* @psalm-param HandlerInterface|callable(?array, FingersCrossedHandler): HandlerInterface $handler
*
* @param callable|HandlerInterface $handler Handler or factory callable($record|null, $fingersCrossedHandler). * @param callable|HandlerInterface $handler Handler or factory callable($record|null, $fingersCrossedHandler).
* @param int|string|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action, or a level name/value at which the handler is activated * @param int|string|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action, or a level name/value at which the handler is activated
* @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. * @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.

View File

@@ -25,6 +25,8 @@ class MandrillHandler extends MailHandler
protected $apiKey; protected $apiKey;
/** /**
* @psalm-param Swift_Message|callable(string, array): Swift_Message $message
*
* @param string $apiKey A valid Mandrill API key * @param string $apiKey A valid Mandrill API key
* @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced * @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced
* @param string|int $level The minimum logging level at which this handler will be triggered * @param string|int $level The minimum logging level at which this handler will be triggered

View File

@@ -23,6 +23,8 @@ interface ProcessableHandlerInterface
/** /**
* Adds a processor in the stack. * Adds a processor in the stack.
* *
* @psalm-param ProcessorInterface|callable(array): array $callback
*
* @param ProcessorInterface|callable $callback * @param ProcessorInterface|callable $callback
* @return HandlerInterface self * @return HandlerInterface self
*/ */
@@ -31,6 +33,8 @@ interface ProcessableHandlerInterface
/** /**
* Removes the processor on top of the stack and returns it. * Removes the processor on top of the stack and returns it.
* *
* @psalm-return callable(array): array
*
* @throws \LogicException In case the processor stack is empty * @throws \LogicException In case the processor stack is empty
* @return callable * @return callable
*/ */

View File

@@ -42,6 +42,8 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
protected $factor; protected $factor;
/** /**
* @psalm-param HandlerInterface|callable(array, HandlerInterface): HandlerInterface $handler
*
* @param callable|HandlerInterface $handler Handler or factory callable($record|null, $samplingHandler). * @param callable|HandlerInterface $handler Handler or factory callable($record|null, $samplingHandler).
* @param int $factor Sample factor (e.g. 10 means every ~10th record is sampled) * @param int $factor Sample factor (e.g. 10 means every ~10th record is sampled)
*/ */

View File

@@ -28,6 +28,8 @@ class SwiftMailerHandler extends MailHandler
private $messageTemplate; private $messageTemplate;
/** /**
* @psalm-param Swift_Message|callable(string, array): Swift_Message $message
*
* @param \Swift_Mailer $mailer The mailer to use * @param \Swift_Mailer $mailer The mailer to use
* @param callable|Swift_Message $message An example message for real messages, only the body will be replaced * @param callable|Swift_Message $message An example message for real messages, only the body will be replaced
* @param string|int $level The minimum logging level at which this handler will be triggered * @param string|int $level The minimum logging level at which this handler will be triggered

View File

@@ -139,13 +139,16 @@ class TestHandler extends AbstractProcessingHandler
*/ */
public function hasRecordThatMatches(string $regex, $level): bool public function hasRecordThatMatches(string $regex, $level): bool
{ {
return $this->hasRecordThatPasses(function ($rec) use ($regex) { return $this->hasRecordThatPasses(function (array $rec) use ($regex): bool {
return preg_match($regex, $rec['message']) > 0; return preg_match($regex, $rec['message']) > 0;
}, $level); }, $level);
} }
/** /**
* @psalm-param callable(array, int): mixed $predicate
*
* @param string|int $level Logging level value or name * @param string|int $level Logging level value or name
* @return bool
*/ */
public function hasRecordThatPasses(callable $predicate, $level) public function hasRecordThatPasses(callable $predicate, $level)
{ {

View File

@@ -140,6 +140,8 @@ class Logger implements LoggerInterface, ResettableInterface
protected $exceptionHandler; protected $exceptionHandler;
/** /**
* @psalm-param array<callable(array): array> $processors
*
* @param string $name The logging channel, a simple descriptive name that is attached to all log records * @param string $name The logging channel, a simple descriptive name that is attached to all log records
* @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc. * @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc.
* @param callable[] $processors Optional array of processors * @param callable[] $processors Optional array of processors