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

More type fixes towards level 7

This commit is contained in:
Jordi Boggiano
2021-05-28 21:59:26 +02:00
parent 01d104aa78
commit 13d40f953f
34 changed files with 26 additions and 67 deletions

View File

@@ -13,6 +13,7 @@ namespace Monolog\Handler;
use Monolog\Logger; use Monolog\Logger;
use Monolog\ResettableInterface; use Monolog\ResettableInterface;
use Psr\Log\LogLevel;
/** /**
* Base Handler class providing basic level/bubble support * Base Handler class providing basic level/bubble support
@@ -20,6 +21,7 @@ use Monolog\ResettableInterface;
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
* *
* @phpstan-import-type Level from \Monolog\Logger * @phpstan-import-type Level from \Monolog\Logger
* @phpstan-import-type LevelName from \Monolog\Logger
*/ */
abstract class AbstractHandler extends Handler implements ResettableInterface abstract class AbstractHandler extends Handler implements ResettableInterface
{ {
@@ -34,6 +36,8 @@ abstract class AbstractHandler extends Handler implements ResettableInterface
/** /**
* @param int|string $level The minimum logging level at which this handler will be triggered * @param int|string $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*
* @phpstan-param Level|LevelName|LogLevel::* $level
*/ */
public function __construct($level = Logger::DEBUG, bool $bubble = true) public function __construct($level = Logger::DEBUG, bool $bubble = true)
{ {
@@ -52,7 +56,7 @@ abstract class AbstractHandler extends Handler implements ResettableInterface
/** /**
* Sets minimum logging level at which this handler will be triggered. * Sets minimum logging level at which this handler will be triggered.
* *
* @param int|string $level Level or level name * @param Level|LevelName|LogLevel::* $level Level or level name
* @return self * @return self
*/ */
public function setLevel($level): self public function setLevel($level): self

View File

@@ -61,8 +61,6 @@ abstract class AbstractSyslogHandler extends AbstractProcessingHandler
/** /**
* @param string|int $facility Either one of the names of the keys in $this->facilities, or a LOG_* facility constant * @param string|int $facility Either one of the names of the keys in $this->facilities, or a LOG_* facility constant
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct($facility = LOG_USER, $level = Logger::DEBUG, bool $bubble = true) public function __construct($facility = LOG_USER, $level = Logger::DEBUG, bool $bubble = true)
{ {

View File

@@ -36,8 +36,6 @@ class AmqpHandler extends AbstractProcessingHandler
/** /**
* @param AMQPExchange|AMQPChannel $exchange AMQPExchange (php AMQP ext) or PHP AMQP lib channel, ready for use * @param AMQPExchange|AMQPChannel $exchange AMQPExchange (php AMQP ext) or PHP AMQP lib channel, ready for use
* @param string|null $exchangeName Optional exchange name, for AMQPChannel (PhpAmqpLib) only * @param string|null $exchangeName Optional exchange name, for AMQPChannel (PhpAmqpLib) only
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct($exchange, ?string $exchangeName = null, $level = Logger::DEBUG, bool $bubble = true) public function __construct($exchange, ?string $exchangeName = null, $level = Logger::DEBUG, bool $bubble = true)
{ {

View File

@@ -45,8 +45,6 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
/** /**
* @param HandlerInterface $handler Handler. * @param HandlerInterface $handler Handler.
* @param int $bufferLimit How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. * @param int $bufferLimit How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
* @param bool $flushOnOverflow If true, the buffer is flushed when the max size has been reached, by default oldest entries are discarded * @param bool $flushOnOverflow If true, the buffer is flushed when the max size has been reached, by default oldest entries are discarded
*/ */
public function __construct(HandlerInterface $handler, int $bufferLimit = 0, $level = Logger::DEBUG, bool $bubble = true, bool $flushOnOverflow = false) public function __construct(HandlerInterface $handler, int $bufferLimit = 0, $level = Logger::DEBUG, bool $bubble = true, bool $flushOnOverflow = false)

View File

@@ -64,10 +64,6 @@ class ChromePHPHandler extends AbstractProcessingHandler
/** @var bool */ /** @var bool */
protected static $sendHeaders = true; protected static $sendHeaders = true;
/**
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct($level = Logger::DEBUG, bool $bubble = true) public function __construct($level = Logger::DEBUG, bool $bubble = true)
{ {
parent::__construct($level, $bubble); parent::__construct($level, $bubble);

View File

@@ -48,9 +48,6 @@ class DynamoDbHandler extends AbstractProcessingHandler
*/ */
protected $marshaler; protected $marshaler;
/**
* @param int|string $level
*/
public function __construct(DynamoDbClient $client, string $table, $level = Logger::DEBUG, bool $bubble = true) public function __construct(DynamoDbClient $client, string $table, $level = Logger::DEBUG, bool $bubble = true)
{ {
/** @phpstan-ignore-next-line */ /** @phpstan-ignore-next-line */

View File

@@ -49,8 +49,6 @@ class ElasticaHandler extends AbstractProcessingHandler
/** /**
* @param Client $client Elastica Client object * @param Client $client Elastica Client object
* @param mixed[] $options Handler configuration * @param mixed[] $options Handler configuration
* @param int|string $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct(Client $client, array $options = [], $level = Logger::DEBUG, bool $bubble = true) public function __construct(Client $client, array $options = [], $level = Logger::DEBUG, bool $bubble = true)
{ {

View File

@@ -56,8 +56,6 @@ class ElasticsearchHandler extends AbstractProcessingHandler
/** /**
* @param Client $client Elasticsearch Client object * @param Client $client Elasticsearch Client object
* @param mixed[] $options Handler configuration * @param mixed[] $options Handler configuration
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct(Client $client, array $options = [], $level = Logger::DEBUG, bool $bubble = true) public function __construct(Client $client, array $options = [], $level = Logger::DEBUG, bool $bubble = true)
{ {

View File

@@ -32,8 +32,6 @@ class ErrorLogHandler extends AbstractProcessingHandler
/** /**
* @param int $messageType Says where the error should go. * @param int $messageType Says where the error should go.
* @param int|string $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
* @param bool $expandNewlines If set to true, newlines in the message will be expanded to be take multiple log entries * @param bool $expandNewlines If set to true, newlines in the message will be expanded to be take multiple log entries
*/ */
public function __construct(int $messageType = self::OPERATING_SYSTEM, $level = Logger::DEBUG, bool $bubble = true, bool $expandNewlines = false) public function __construct(int $messageType = self::OPERATING_SYSTEM, $level = Logger::DEBUG, bool $bubble = true, bool $expandNewlines = false)

View File

@@ -31,8 +31,6 @@ class GelfHandler extends AbstractProcessingHandler
/** /**
* @param PublisherInterface $publisher a publisher object * @param PublisherInterface $publisher a publisher object
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct(PublisherInterface $publisher, $level = Logger::DEBUG, bool $bubble = true) public function __construct(PublisherInterface $publisher, $level = Logger::DEBUG, bool $bubble = true)
{ {

View File

@@ -35,8 +35,6 @@ class IFTTTHandler extends AbstractProcessingHandler
/** /**
* @param string $eventName The name of the IFTTT Maker event that should be triggered * @param string $eventName The name of the IFTTT Maker event that should be triggered
* @param string $secretKey A valid IFTTT secret key * @param string $secretKey A valid IFTTT secret key
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct(string $eventName, string $secretKey, $level = Logger::ERROR, bool $bubble = true) public function __construct(string $eventName, string $secretKey, $level = Logger::ERROR, bool $bubble = true)
{ {

View File

@@ -45,8 +45,6 @@ class LogglyHandler extends AbstractProcessingHandler
/** /**
* @param string $token API token supplied by Loggly * @param string $token API token supplied by Loggly
* @param string|int $level The minimum logging level to trigger this handler
* @param bool $bubble Whether or not messages that are handled should bubble up the stack.
* *
* @throws MissingExtensionException If the curl extension is missing * @throws MissingExtensionException If the curl extension is missing
*/ */

View File

@@ -32,8 +32,6 @@ class MandrillHandler extends MailHandler
* *
* @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 bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct(string $apiKey, $message, $level = Logger::ERROR, bool $bubble = true) public function __construct(string $apiKey, $message, $level = Logger::ERROR, bool $bubble = true)
{ {

View File

@@ -46,8 +46,6 @@ class MongoDBHandler extends AbstractProcessingHandler
* @param Client|Manager $mongodb MongoDB library or driver client * @param Client|Manager $mongodb MongoDB library or driver client
* @param string $database Database name * @param string $database Database name
* @param string $collection Collection name * @param string $collection Collection name
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct($mongodb, string $database, string $collection, $level = Logger::DEBUG, bool $bubble = true) public function __construct($mongodb, string $database, string $collection, $level = Logger::DEBUG, bool $bubble = true)
{ {

View File

@@ -68,8 +68,6 @@ class NativeMailerHandler extends MailHandler
* @param string|string[] $to The receiver of the mail * @param string|string[] $to The receiver of the mail
* @param string $subject The subject of the mail * @param string $subject The subject of the mail
* @param string $from The sender of the mail * @param string $from The sender of the mail
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
* @param int $maxColumnWidth The maximum column width that the message lines will have * @param int $maxColumnWidth The maximum column width that the message lines will have
*/ */
public function __construct($to, string $subject, string $from, $level = Logger::ERROR, bool $bubble = true, int $maxColumnWidth = 70) public function __construct($to, string $subject, string $from, $level = Logger::ERROR, bool $bubble = true, int $maxColumnWidth = 70)

View File

@@ -52,8 +52,6 @@ class NewRelicHandler extends AbstractProcessingHandler
/** /**
* {@inheritDoc} * {@inheritDoc}
* *
* @param string|int $level The minimum logging level at which this handler will be triggered.
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not.
* @param string|null $appName * @param string|null $appName
* @param bool $explodeArrays * @param bool $explodeArrays
* @param string|null $transactionName * @param string|null $transactionName

View File

@@ -12,6 +12,7 @@
namespace Monolog\Handler; namespace Monolog\Handler;
use Monolog\Logger; use Monolog\Logger;
use Psr\Log\LogLevel;
/** /**
* Blackhole * Blackhole
@@ -20,6 +21,9 @@ use Monolog\Logger;
* to put on top of an existing stack to override it temporarily. * to put on top of an existing stack to override it temporarily.
* *
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*
* @phpstan-import-type Level from \Monolog\Logger
* @phpstan-import-type LevelName from \Monolog\Logger
*/ */
class NullHandler extends Handler class NullHandler extends Handler
{ {
@@ -30,6 +34,8 @@ class NullHandler extends Handler
/** /**
* @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
*
* @phpstan-param Level|LevelName|LogLevel::* $level
*/ */
public function __construct($level = Logger::DEBUG) public function __construct($level = Logger::DEBUG)
{ {

View File

@@ -61,8 +61,6 @@ class OverflowHandler extends AbstractHandler implements FormattableHandlerInter
/** /**
* @param HandlerInterface $handler * @param HandlerInterface $handler
* @param int[] $thresholdMap Dictionary of logger level => threshold * @param int[] $thresholdMap Dictionary of logger level => threshold
* @param int|string $level The minimum logging level at which this handler will be triggered
* @param bool $bubble
*/ */
public function __construct( public function __construct(
HandlerInterface $handler, HandlerInterface $handler,

View File

@@ -72,8 +72,6 @@ class PHPConsoleHandler extends AbstractProcessingHandler
/** /**
* @param array<string, mixed> $options See \Monolog\Handler\PHPConsoleHandler::$options for more details * @param array<string, mixed> $options See \Monolog\Handler\PHPConsoleHandler::$options for more details
* @param Connector|null $connector Instance of \PhpConsole\Connector class (optional) * @param Connector|null $connector Instance of \PhpConsole\Connector class (optional)
* @param string|int $level The minimum logging level at which this handler will be triggered.
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not.
* @throws \RuntimeException * @throws \RuntimeException
*/ */
public function __construct(array $options = [], ?Connector $connector = null, $level = Logger::DEBUG, bool $bubble = true) public function __construct(array $options = [], ?Connector $connector = null, $level = Logger::DEBUG, bool $bubble = true)

View File

@@ -60,8 +60,6 @@ class ProcessHandler extends AbstractProcessingHandler
/** /**
* @param string $command Command for the process to start. Absolute paths are recommended, * @param string $command Command for the process to start. Absolute paths are recommended,
* especially if you do not use the $cwd parameter. * especially if you do not use the $cwd parameter.
* @param string|int $level The minimum logging level at which this handler will be triggered.
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not.
* @param string|null $cwd "Current working directory" (CWD) for the process to be executed in. * @param string|null $cwd "Current working directory" (CWD) for the process to be executed in.
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */

View File

@@ -40,8 +40,6 @@ class PsrHandler extends AbstractHandler implements FormattableHandlerInterface
/** /**
* @param LoggerInterface $logger The underlying PSR-3 compliant logger to which messages will be proxied * @param LoggerInterface $logger The underlying PSR-3 compliant logger to which messages will be proxied
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct(LoggerInterface $logger, $level = Logger::DEBUG, bool $bubble = true) public function __construct(LoggerInterface $logger, $level = Logger::DEBUG, bool $bubble = true)
{ {

View File

@@ -40,8 +40,6 @@ class RedisHandler extends AbstractProcessingHandler
/** /**
* @param \Predis\Client|\Redis $redis The redis instance * @param \Predis\Client|\Redis $redis The redis instance
* @param string $key The key name to push records to * @param string $key The key name to push records to
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
* @param int $capSize Number of entries to limit list size to, 0 = unlimited * @param int $capSize Number of entries to limit list size to, 0 = unlimited
*/ */
public function __construct($redis, string $key, $level = Logger::DEBUG, bool $bubble = true, int $capSize = 0) public function __construct($redis, string $key, $level = Logger::DEBUG, bool $bubble = true, int $capSize = 0)

View File

@@ -36,8 +36,6 @@ class RedisPubSubHandler extends AbstractProcessingHandler
/** /**
* @param \Predis\Client|\Redis $redis The redis instance * @param \Predis\Client|\Redis $redis The redis instance
* @param string $key The channel key to publish records to * @param string $key The channel key to publish records to
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct($redis, string $key, $level = Logger::DEBUG, bool $bubble = true) public function __construct($redis, string $key, $level = Logger::DEBUG, bool $bubble = true)
{ {

View File

@@ -62,8 +62,6 @@ class RollbarHandler extends AbstractProcessingHandler
/** /**
* @param RollbarLogger $rollbarLogger RollbarLogger object constructed with valid token * @param RollbarLogger $rollbarLogger RollbarLogger object constructed with valid token
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct(RollbarLogger $rollbarLogger, $level = Logger::ERROR, bool $bubble = true) public function __construct(RollbarLogger $rollbarLogger, $level = Logger::ERROR, bool $bubble = true)
{ {

View File

@@ -56,8 +56,6 @@ class SendGridHandler extends MailHandler
* @param string $from The sender of the email * @param string $from The sender of the email
* @param string|string[] $to The recipients of the email * @param string|string[] $to The recipients of the email
* @param string $subject The subject of the mail * @param string $subject The subject of the mail
* @param int|string $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct(string $apiUser, string $apiKey, string $from, $to, string $subject, $level = Logger::ERROR, bool $bubble = true) public function __construct(string $apiUser, string $apiKey, string $from, $to, string $subject, $level = Logger::ERROR, bool $bubble = true)
{ {

View File

@@ -44,8 +44,6 @@ class SlackHandler extends SocketHandler
* @param string|null $username Name of a bot * @param string|null $username Name of a bot
* @param bool $useAttachment Whether the message should be added to Slack as attachment (plain text otherwise) * @param bool $useAttachment Whether the message should be added to Slack as attachment (plain text otherwise)
* @param string|null $iconEmoji The emoji name to use (or null) * @param string|null $iconEmoji The emoji name to use (or null)
* @param int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
* @param bool $useShortAttachment Whether the context/extra messages added to Slack as attachments are in a short style * @param bool $useShortAttachment Whether the context/extra messages added to Slack as attachments are in a short style
* @param bool $includeContextAndExtra Whether the attachment should include context and extra data * @param bool $includeContextAndExtra Whether the attachment should include context and extra data
* @param string[] $excludeFields Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2'] * @param string[] $excludeFields Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2']

View File

@@ -44,8 +44,6 @@ class SlackWebhookHandler extends AbstractProcessingHandler
* @param string|null $iconEmoji The emoji name to use (or null) * @param string|null $iconEmoji The emoji name to use (or null)
* @param bool $useShortAttachment Whether the the context/extra messages added to Slack as attachments are in a short style * @param bool $useShortAttachment Whether the the context/extra messages added to Slack as attachments are in a short style
* @param bool $includeContextAndExtra Whether the attachment should include context and extra data * @param bool $includeContextAndExtra Whether the attachment should include context and extra data
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
* @param string[] $excludeFields Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2'] * @param string[] $excludeFields Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2']
*/ */
public function __construct( public function __construct(

View File

@@ -48,9 +48,7 @@ class SocketHandler extends AbstractProcessingHandler
private $lastWritingAt = null; private $lastWritingAt = null;
/** /**
* @param string $connectionString Socket connection string * @param string $connectionString Socket connection string
* @param int|string $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct(string $connectionString, $level = Logger::DEBUG, bool $bubble = true) public function __construct(string $connectionString, $level = Logger::DEBUG, bool $bubble = true)
{ {

View File

@@ -42,8 +42,6 @@ class StreamHandler extends AbstractProcessingHandler
/** /**
* @param resource|string $stream If a missing path can't be created, an UnexpectedValueException will be thrown on first write * @param resource|string $stream If a missing path can't be created, an UnexpectedValueException will be thrown on first write
* @param string|int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
* @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write) * @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write)
* @param bool $useLocking Try to lock log file before doing any writes * @param bool $useLocking Try to lock log file before doing any writes
* *

View File

@@ -36,8 +36,6 @@ class SwiftMailerHandler extends MailHandler
* *
* @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 bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, bool $bubble = true) public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, bool $bubble = true)
{ {

View File

@@ -78,7 +78,6 @@ class TelegramBotHandler extends AbstractProcessingHandler
/** /**
* @param string $apiKey Telegram bot access token provided by BotFather * @param string $apiKey Telegram bot access token provided by BotFather
* @param string $channel Telegram channel name * @param string $channel Telegram channel name
* @inheritDoc
*/ */
public function __construct( public function __construct(
string $apiKey, string $apiKey,

View File

@@ -33,8 +33,6 @@ class ZendMonitorHandler extends AbstractProcessingHandler
protected $levelMap = []; protected $levelMap = [];
/** /**
* @param string|int $level The minimum logging level at which this handler will be triggered.
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not.
* @throws MissingExtensionException * @throws MissingExtensionException
*/ */
public function __construct($level = Logger::DEBUG, bool $bubble = true) public function __construct($level = Logger::DEBUG, bool $bubble = true)

View File

@@ -12,21 +12,27 @@
namespace Monolog\Processor; namespace Monolog\Processor;
use Monolog\Logger; use Monolog\Logger;
use Psr\Log\LogLevel;
/** /**
* Injects Hg branch and Hg revision number in all records * Injects Hg branch and Hg revision number in all records
* *
* @author Jonathan A. Schweder <jonathanschweder@gmail.com> * @author Jonathan A. Schweder <jonathanschweder@gmail.com>
*
* @phpstan-import-type LevelName from \Monolog\Logger
* @phpstan-import-type Level from \Monolog\Logger
*/ */
class MercurialProcessor implements ProcessorInterface class MercurialProcessor implements ProcessorInterface
{ {
/** @var int */ /** @var Level */
private $level; private $level;
/** @var array{branch: string, revision: string}|array<never>|null */ /** @var array{branch: string, revision: string}|array<never>|null */
private static $cache = null; private static $cache = null;
/** /**
* @param string|int $level The minimum logging level at which this Processor will be triggered * @param int|string $level The minimum logging level at which this Processor will be triggered
*
* @phpstan-param Level|LevelName|LogLevel::* $level
*/ */
public function __construct($level = Logger::DEBUG) public function __construct($level = Logger::DEBUG)
{ {

View File

@@ -19,13 +19,16 @@ use ReflectionExtension;
* Monolog POSIX signal handler * Monolog POSIX signal handler
* *
* @author Robert Gust-Bardon <robert@gust-bardon.org> * @author Robert Gust-Bardon <robert@gust-bardon.org>
*
* @phpstan-import-type Level from \Monolog\Logger
* @phpstan-import-type LevelName from \Monolog\Logger
*/ */
class SignalHandler class SignalHandler
{ {
/** @var LoggerInterface */ /** @var LoggerInterface */
private $logger; private $logger;
/** @var array<int, callable|int> SIG_DFL, SIG_IGN or previous callable */ /** @var array<int, callable|string|int> SIG_DFL, SIG_IGN or previous callable */
private $previousSignalHandler = []; private $previousSignalHandler = [];
/** @var array<int, int> */ /** @var array<int, int> */
private $signalLevelMap = []; private $signalLevelMap = [];
@@ -43,6 +46,8 @@ class SignalHandler
* @param bool $restartSyscalls * @param bool $restartSyscalls
* @param bool|null $async * @param bool|null $async
* @return $this * @return $this
*
* @phpstan-param Level|LevelName|LogLevel::* $level
*/ */
public function registerSignalHandler(int $signo, $level = LogLevel::CRITICAL, bool $callPrevious = true, bool $restartSyscalls = true, ?bool $async = true): self public function registerSignalHandler(int $signo, $level = LogLevel::CRITICAL, bool $callPrevious = true, bool $restartSyscalls = true, ?bool $async = true): self
{ {