diff --git a/src/Monolog/Handler/FilterHandler.php b/src/Monolog/Handler/FilterHandler.php index 77b45b99..ee1304d6 100644 --- a/src/Monolog/Handler/FilterHandler.php +++ b/src/Monolog/Handler/FilterHandler.php @@ -49,6 +49,8 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese protected $bubble; /** + * @psalm-param HandlerInterface|callable(?array, HandlerInterface): HandlerInterface $handler + * * @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|string $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array diff --git a/src/Monolog/Handler/FingersCrossedHandler.php b/src/Monolog/Handler/FingersCrossedHandler.php index 3e529f50..12d55a3a 100644 --- a/src/Monolog/Handler/FingersCrossedHandler.php +++ b/src/Monolog/Handler/FingersCrossedHandler.php @@ -47,6 +47,8 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa protected $bubble; /** + * @psalm-param HandlerInterface|callable(?array, FingersCrossedHandler): HandlerInterface $handler + * * @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 $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. diff --git a/src/Monolog/Handler/MandrillHandler.php b/src/Monolog/Handler/MandrillHandler.php index 46b8bff0..19aeeb3b 100644 --- a/src/Monolog/Handler/MandrillHandler.php +++ b/src/Monolog/Handler/MandrillHandler.php @@ -25,6 +25,8 @@ class MandrillHandler extends MailHandler protected $apiKey; /** + * @psalm-param Swift_Message|callable(string, array): Swift_Message $message + * * @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 string|int $level The minimum logging level at which this handler will be triggered diff --git a/src/Monolog/Handler/ProcessableHandlerInterface.php b/src/Monolog/Handler/ProcessableHandlerInterface.php index 2c9557b4..41b52ce5 100644 --- a/src/Monolog/Handler/ProcessableHandlerInterface.php +++ b/src/Monolog/Handler/ProcessableHandlerInterface.php @@ -23,6 +23,8 @@ interface ProcessableHandlerInterface /** * Adds a processor in the stack. * + * @psalm-param ProcessorInterface|callable(array): array $callback + * * @param ProcessorInterface|callable $callback * @return HandlerInterface self */ @@ -31,6 +33,8 @@ interface ProcessableHandlerInterface /** * 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 * @return callable */ diff --git a/src/Monolog/Handler/SamplingHandler.php b/src/Monolog/Handler/SamplingHandler.php index 29647873..d7953aa7 100644 --- a/src/Monolog/Handler/SamplingHandler.php +++ b/src/Monolog/Handler/SamplingHandler.php @@ -42,6 +42,8 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter protected $factor; /** + * @psalm-param HandlerInterface|callable(array, HandlerInterface): HandlerInterface $handler + * * @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) */ diff --git a/src/Monolog/Handler/SwiftMailerHandler.php b/src/Monolog/Handler/SwiftMailerHandler.php index 66264cb5..27bf6f07 100644 --- a/src/Monolog/Handler/SwiftMailerHandler.php +++ b/src/Monolog/Handler/SwiftMailerHandler.php @@ -28,6 +28,8 @@ class SwiftMailerHandler extends MailHandler private $messageTemplate; /** + * @psalm-param Swift_Message|callable(string, array): Swift_Message $message + * * @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 string|int $level The minimum logging level at which this handler will be triggered diff --git a/src/Monolog/Handler/TestHandler.php b/src/Monolog/Handler/TestHandler.php index 4260f740..568db512 100644 --- a/src/Monolog/Handler/TestHandler.php +++ b/src/Monolog/Handler/TestHandler.php @@ -139,13 +139,16 @@ class TestHandler extends AbstractProcessingHandler */ 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; }, $level); } /** + * @psalm-param callable(array, int): mixed $predicate + * * @param string|int $level Logging level value or name + * @return bool */ public function hasRecordThatPasses(callable $predicate, $level) { diff --git a/src/Monolog/Logger.php b/src/Monolog/Logger.php index 9242f6ee..b8e2db98 100644 --- a/src/Monolog/Logger.php +++ b/src/Monolog/Logger.php @@ -140,6 +140,8 @@ class Logger implements LoggerInterface, ResettableInterface protected $exceptionHandler; /** + * @psalm-param array $processors + * * @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 callable[] $processors Optional array of processors