Ver código fonte

More type fixes towards level 7

Jordi Boggiano 4 anos atrás
pai
commit
13d40f953f
34 arquivos alterados com 26 adições e 67 exclusões
  1. 5 1
      src/Monolog/Handler/AbstractHandler.php
  2. 0 2
      src/Monolog/Handler/AbstractSyslogHandler.php
  3. 0 2
      src/Monolog/Handler/AmqpHandler.php
  4. 0 2
      src/Monolog/Handler/BufferHandler.php
  5. 0 4
      src/Monolog/Handler/ChromePHPHandler.php
  6. 0 3
      src/Monolog/Handler/DynamoDbHandler.php
  7. 0 2
      src/Monolog/Handler/ElasticaHandler.php
  8. 0 2
      src/Monolog/Handler/ElasticsearchHandler.php
  9. 0 2
      src/Monolog/Handler/ErrorLogHandler.php
  10. 0 2
      src/Monolog/Handler/GelfHandler.php
  11. 0 2
      src/Monolog/Handler/IFTTTHandler.php
  12. 0 2
      src/Monolog/Handler/LogglyHandler.php
  13. 0 2
      src/Monolog/Handler/MandrillHandler.php
  14. 0 2
      src/Monolog/Handler/MongoDBHandler.php
  15. 0 2
      src/Monolog/Handler/NativeMailerHandler.php
  16. 0 2
      src/Monolog/Handler/NewRelicHandler.php
  17. 6 0
      src/Monolog/Handler/NullHandler.php
  18. 0 2
      src/Monolog/Handler/OverflowHandler.php
  19. 0 2
      src/Monolog/Handler/PHPConsoleHandler.php
  20. 0 2
      src/Monolog/Handler/ProcessHandler.php
  21. 0 2
      src/Monolog/Handler/PsrHandler.php
  22. 0 2
      src/Monolog/Handler/RedisHandler.php
  23. 0 2
      src/Monolog/Handler/RedisPubSubHandler.php
  24. 0 2
      src/Monolog/Handler/RollbarHandler.php
  25. 0 2
      src/Monolog/Handler/SendGridHandler.php
  26. 0 2
      src/Monolog/Handler/SlackHandler.php
  27. 0 2
      src/Monolog/Handler/SlackWebhookHandler.php
  28. 1 3
      src/Monolog/Handler/SocketHandler.php
  29. 0 2
      src/Monolog/Handler/StreamHandler.php
  30. 0 2
      src/Monolog/Handler/SwiftMailerHandler.php
  31. 0 1
      src/Monolog/Handler/TelegramBotHandler.php
  32. 0 2
      src/Monolog/Handler/ZendMonitorHandler.php
  33. 8 2
      src/Monolog/Processor/MercurialProcessor.php
  34. 6 1
      src/Monolog/SignalHandler.php

+ 5 - 1
src/Monolog/Handler/AbstractHandler.php

@@ -13,6 +13,7 @@ namespace Monolog\Handler;
 
 use Monolog\Logger;
 use Monolog\ResettableInterface;
+use Psr\Log\LogLevel;
 
 /**
  * Base Handler class providing basic level/bubble support
@@ -20,6 +21,7 @@ use Monolog\ResettableInterface;
  * @author Jordi Boggiano <j.boggiano@seld.be>
  *
  * @phpstan-import-type Level from \Monolog\Logger
+ * @phpstan-import-type LevelName from \Monolog\Logger
  */
 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 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)
     {
@@ -52,7 +56,7 @@ abstract class AbstractHandler extends Handler implements ResettableInterface
     /**
      * 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
      */
     public function setLevel($level): self

+ 0 - 2
src/Monolog/Handler/AbstractSyslogHandler.php

@@ -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 $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)
     {

+ 0 - 2
src/Monolog/Handler/AmqpHandler.php

@@ -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 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)
     {

+ 0 - 2
src/Monolog/Handler/BufferHandler.php

@@ -45,8 +45,6 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
     /**
      * @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 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
      */
     public function __construct(HandlerInterface $handler, int $bufferLimit = 0, $level = Logger::DEBUG, bool $bubble = true, bool $flushOnOverflow = false)

+ 0 - 4
src/Monolog/Handler/ChromePHPHandler.php

@@ -64,10 +64,6 @@ class ChromePHPHandler extends AbstractProcessingHandler
     /** @var bool */
     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)
     {
         parent::__construct($level, $bubble);

+ 0 - 3
src/Monolog/Handler/DynamoDbHandler.php

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

+ 0 - 2
src/Monolog/Handler/ElasticaHandler.php

@@ -49,8 +49,6 @@ class ElasticaHandler extends AbstractProcessingHandler
     /**
      * @param Client     $client  Elastica Client object
      * @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)
     {

+ 0 - 2
src/Monolog/Handler/ElasticsearchHandler.php

@@ -56,8 +56,6 @@ class ElasticsearchHandler extends AbstractProcessingHandler
     /**
      * @param Client     $client  Elasticsearch Client object
      * @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)
     {

+ 0 - 2
src/Monolog/Handler/ErrorLogHandler.php

@@ -32,8 +32,6 @@ class ErrorLogHandler extends AbstractProcessingHandler
 
     /**
      * @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
      */
     public function __construct(int $messageType = self::OPERATING_SYSTEM, $level = Logger::DEBUG, bool $bubble = true, bool $expandNewlines = false)

+ 0 - 2
src/Monolog/Handler/GelfHandler.php

@@ -31,8 +31,6 @@ class GelfHandler extends AbstractProcessingHandler
 
     /**
      * @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)
     {

+ 0 - 2
src/Monolog/Handler/IFTTTHandler.php

@@ -35,8 +35,6 @@ class IFTTTHandler extends AbstractProcessingHandler
     /**
      * @param string     $eventName The name of the IFTTT Maker event that should be triggered
      * @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)
     {

+ 0 - 2
src/Monolog/Handler/LogglyHandler.php

@@ -45,8 +45,6 @@ class LogglyHandler extends AbstractProcessingHandler
 
     /**
      * @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
      */

+ 0 - 2
src/Monolog/Handler/MandrillHandler.php

@@ -32,8 +32,6 @@ class MandrillHandler extends MailHandler
      *
      * @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
-     * @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)
     {

+ 0 - 2
src/Monolog/Handler/MongoDBHandler.php

@@ -46,8 +46,6 @@ class MongoDBHandler extends AbstractProcessingHandler
      * @param Client|Manager $mongodb    MongoDB library or driver client
      * @param string         $database   Database 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)
     {

+ 0 - 2
src/Monolog/Handler/NativeMailerHandler.php

@@ -68,8 +68,6 @@ class NativeMailerHandler extends MailHandler
      * @param string|string[] $to             The receiver of the mail
      * @param string       $subject        The subject 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
      */
     public function __construct($to, string $subject, string $from, $level = Logger::ERROR, bool $bubble = true, int $maxColumnWidth = 70)

+ 0 - 2
src/Monolog/Handler/NewRelicHandler.php

@@ -52,8 +52,6 @@ class NewRelicHandler extends AbstractProcessingHandler
     /**
      * {@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 bool        $explodeArrays
      * @param string|null $transactionName

+ 6 - 0
src/Monolog/Handler/NullHandler.php

@@ -12,6 +12,7 @@
 namespace Monolog\Handler;
 
 use Monolog\Logger;
+use Psr\Log\LogLevel;
 
 /**
  * Blackhole
@@ -20,6 +21,9 @@ use Monolog\Logger;
  * to put on top of an existing stack to override it temporarily.
  *
  * @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
 {
@@ -30,6 +34,8 @@ class NullHandler extends Handler
 
     /**
      * @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)
     {

+ 0 - 2
src/Monolog/Handler/OverflowHandler.php

@@ -61,8 +61,6 @@ class OverflowHandler extends AbstractHandler implements FormattableHandlerInter
     /**
      * @param HandlerInterface $handler
      * @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(
         HandlerInterface $handler,

+ 0 - 2
src/Monolog/Handler/PHPConsoleHandler.php

@@ -72,8 +72,6 @@ class PHPConsoleHandler extends AbstractProcessingHandler
     /**
      * @param  array<string, mixed> $options   See \Monolog\Handler\PHPConsoleHandler::$options for more details
      * @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
      */
     public function __construct(array $options = [], ?Connector $connector = null, $level = Logger::DEBUG, bool $bubble = true)

+ 0 - 2
src/Monolog/Handler/ProcessHandler.php

@@ -60,8 +60,6 @@ class ProcessHandler extends AbstractProcessingHandler
     /**
      * @param  string                    $command Command for the process to start. Absolute paths are recommended,
      *                                            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.
      * @throws \InvalidArgumentException
      */

+ 0 - 2
src/Monolog/Handler/PsrHandler.php

@@ -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 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)
     {

+ 0 - 2
src/Monolog/Handler/RedisHandler.php

@@ -40,8 +40,6 @@ class RedisHandler extends AbstractProcessingHandler
     /**
      * @param \Predis\Client|\Redis $redis   The redis instance
      * @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
      */
     public function __construct($redis, string $key, $level = Logger::DEBUG, bool $bubble = true, int $capSize = 0)

+ 0 - 2
src/Monolog/Handler/RedisPubSubHandler.php

@@ -36,8 +36,6 @@ class RedisPubSubHandler extends AbstractProcessingHandler
     /**
      * @param \Predis\Client|\Redis $redis  The redis instance
      * @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)
     {

+ 0 - 2
src/Monolog/Handler/RollbarHandler.php

@@ -62,8 +62,6 @@ class RollbarHandler extends AbstractProcessingHandler
 
     /**
      * @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)
     {

+ 0 - 2
src/Monolog/Handler/SendGridHandler.php

@@ -56,8 +56,6 @@ class SendGridHandler extends MailHandler
      * @param string          $from    The sender of the email
      * @param string|string[] $to      The recipients of the email
      * @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)
     {

+ 0 - 2
src/Monolog/Handler/SlackHandler.php

@@ -44,8 +44,6 @@ class SlackHandler extends SocketHandler
      * @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  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                      $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']

+ 0 - 2
src/Monolog/Handler/SlackWebhookHandler.php

@@ -44,8 +44,6 @@ class SlackWebhookHandler extends AbstractProcessingHandler
      * @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        $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']
      */
     public function __construct(

+ 1 - 3
src/Monolog/Handler/SocketHandler.php

@@ -48,9 +48,7 @@ class SocketHandler extends AbstractProcessingHandler
     private $lastWritingAt = null;
 
     /**
-     * @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
+     * @param string $connectionString Socket connection string
      */
     public function __construct(string $connectionString, $level = Logger::DEBUG, bool $bubble = true)
     {

+ 0 - 2
src/Monolog/Handler/StreamHandler.php

@@ -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 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 bool            $useLocking     Try to lock log file before doing any writes
      *

+ 0 - 2
src/Monolog/Handler/SwiftMailerHandler.php

@@ -36,8 +36,6 @@ class SwiftMailerHandler extends MailHandler
      *
      * @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
-     * @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)
     {

+ 0 - 1
src/Monolog/Handler/TelegramBotHandler.php

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

+ 0 - 2
src/Monolog/Handler/ZendMonitorHandler.php

@@ -33,8 +33,6 @@ class ZendMonitorHandler extends AbstractProcessingHandler
     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
      */
     public function __construct($level = Logger::DEBUG, bool $bubble = true)

+ 8 - 2
src/Monolog/Processor/MercurialProcessor.php

@@ -12,21 +12,27 @@
 namespace Monolog\Processor;
 
 use Monolog\Logger;
+use Psr\Log\LogLevel;
 
 /**
  * Injects Hg branch and Hg revision number in all records
  *
  * @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
 {
-    /** @var int */
+    /** @var Level */
     private $level;
     /** @var array{branch: string, revision: string}|array<never>|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)
     {

+ 6 - 1
src/Monolog/SignalHandler.php

@@ -19,13 +19,16 @@ use ReflectionExtension;
  * Monolog POSIX signal handler
  *
  * @author Robert Gust-Bardon <robert@gust-bardon.org>
+ *
+ * @phpstan-import-type Level from \Monolog\Logger
+ * @phpstan-import-type LevelName from \Monolog\Logger
  */
 class SignalHandler
 {
     /** @var LoggerInterface */
     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 = [];
     /** @var array<int, int> */
     private $signalLevelMap = [];
@@ -43,6 +46,8 @@ class SignalHandler
      * @param bool      $restartSyscalls
      * @param bool|null $async
      * @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
     {