diff --git a/doc/04-extending.md b/doc/04-extending.md index f5d292ad..8d9d09a4 100644 --- a/doc/04-extending.md +++ b/doc/04-extending.md @@ -30,7 +30,7 @@ class PDOHandler extends AbstractProcessingHandler private PDO $pdo; private PDOStatement $statement; - public function __construct(PDO $pdo, $level = Level::Debug, bool $bubble = true) + public function __construct(PDO $pdo, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { $this->pdo = $pdo; parent::__construct($level, $bubble); diff --git a/src/Monolog/Handler/AbstractSyslogHandler.php b/src/Monolog/Handler/AbstractSyslogHandler.php index 8535ab84..0315d981 100644 --- a/src/Monolog/Handler/AbstractSyslogHandler.php +++ b/src/Monolog/Handler/AbstractSyslogHandler.php @@ -14,6 +14,7 @@ namespace Monolog\Handler; use Monolog\Level; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\LineFormatter; +use Monolog\LevelName; /** * Common syslog functionality @@ -60,7 +61,7 @@ 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 */ - public function __construct($facility = \LOG_USER, $level = Level::Debug, bool $bubble = true) + public function __construct(string|int $facility = \LOG_USER, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { parent::__construct($level, $bubble); diff --git a/src/Monolog/Handler/ChromePHPHandler.php b/src/Monolog/Handler/ChromePHPHandler.php index 8882fabb..f6914bd0 100644 --- a/src/Monolog/Handler/ChromePHPHandler.php +++ b/src/Monolog/Handler/ChromePHPHandler.php @@ -14,6 +14,7 @@ namespace Monolog\Handler; use Monolog\Formatter\ChromePHPFormatter; use Monolog\Formatter\FormatterInterface; use Monolog\Level; +use Monolog\LevelName; use Monolog\Utils; use Monolog\LogRecord; use Monolog\DateTimeImmutable; @@ -62,7 +63,7 @@ class ChromePHPHandler extends AbstractProcessingHandler protected static bool $sendHeaders = true; - public function __construct($level = Level::Debug, bool $bubble = true) + public function __construct(int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { parent::__construct($level, $bubble); if (!function_exists('json_encode')) { diff --git a/src/Monolog/Handler/CouchDBHandler.php b/src/Monolog/Handler/CouchDBHandler.php index 3b97375d..8437ccec 100644 --- a/src/Monolog/Handler/CouchDBHandler.php +++ b/src/Monolog/Handler/CouchDBHandler.php @@ -14,6 +14,7 @@ namespace Monolog\Handler; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\JsonFormatter; use Monolog\Level; +use Monolog\LevelName; use Monolog\LogRecord; /** @@ -48,7 +49,7 @@ class CouchDBHandler extends AbstractProcessingHandler * * @phpstan-param InputOptions $options */ - public function __construct(array $options = [], $level = Level::Debug, bool $bubble = true) + public function __construct(array $options = [], int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { $this->options = array_merge([ 'host' => 'localhost', diff --git a/src/Monolog/Handler/CubeHandler.php b/src/Monolog/Handler/CubeHandler.php index c2469ca6..1f8ea384 100644 --- a/src/Monolog/Handler/CubeHandler.php +++ b/src/Monolog/Handler/CubeHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Level; +use Monolog\LevelName; use Monolog\Utils; use Monolog\LogRecord; @@ -38,7 +39,7 @@ class CubeHandler extends AbstractProcessingHandler * A valid url must consist of three parts : protocol://host:port * Only valid protocols used by Cube are http and udp */ - public function __construct(string $url, $level = Level::Debug, bool $bubble = true) + public function __construct(string $url, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { $urlInfo = parse_url($url); diff --git a/src/Monolog/Handler/DoctrineCouchDBHandler.php b/src/Monolog/Handler/DoctrineCouchDBHandler.php index 44d2ff5c..fad4ac9d 100644 --- a/src/Monolog/Handler/DoctrineCouchDBHandler.php +++ b/src/Monolog/Handler/DoctrineCouchDBHandler.php @@ -15,6 +15,7 @@ use Monolog\Level; use Monolog\Formatter\NormalizerFormatter; use Monolog\Formatter\FormatterInterface; use Doctrine\CouchDB\CouchDBClient; +use Monolog\LevelName; use Monolog\LogRecord; /** @@ -26,7 +27,7 @@ class DoctrineCouchDBHandler extends AbstractProcessingHandler { private CouchDBClient $client; - public function __construct(CouchDBClient $client, $level = Level::Debug, bool $bubble = true) + public function __construct(CouchDBClient $client, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { $this->client = $client; parent::__construct($level, $bubble); diff --git a/src/Monolog/Handler/DynamoDbHandler.php b/src/Monolog/Handler/DynamoDbHandler.php index c79d484e..e23632fe 100644 --- a/src/Monolog/Handler/DynamoDbHandler.php +++ b/src/Monolog/Handler/DynamoDbHandler.php @@ -17,6 +17,7 @@ use Monolog\Formatter\FormatterInterface; use Aws\DynamoDb\Marshaler; use Monolog\Formatter\ScalarFormatter; use Monolog\Level; +use Monolog\LevelName; use Monolog\LogRecord; /** @@ -35,7 +36,7 @@ class DynamoDbHandler extends AbstractProcessingHandler protected Marshaler $marshaler; - public function __construct(DynamoDbClient $client, string $table, $level = Level::Debug, bool $bubble = true) + public function __construct(DynamoDbClient $client, string $table, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { $this->marshaler = new Marshaler; diff --git a/src/Monolog/Handler/ElasticaHandler.php b/src/Monolog/Handler/ElasticaHandler.php index e9eb0d6a..6c064d71 100644 --- a/src/Monolog/Handler/ElasticaHandler.php +++ b/src/Monolog/Handler/ElasticaHandler.php @@ -17,6 +17,7 @@ use Monolog\Formatter\ElasticaFormatter; use Monolog\Level; use Elastica\Client; use Elastica\Exception\ExceptionInterface; +use Monolog\LevelName; use Monolog\LogRecord; /** @@ -61,7 +62,7 @@ class ElasticaHandler extends AbstractProcessingHandler * * @phpstan-param InputOptions $options */ - public function __construct(Client $client, array $options = [], $level = Level::Debug, bool $bubble = true) + public function __construct(Client $client, array $options = [], int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { parent::__construct($level, $bubble); $this->client = $client; diff --git a/src/Monolog/Handler/ElasticsearchHandler.php b/src/Monolog/Handler/ElasticsearchHandler.php index 2b14e33b..55679afb 100644 --- a/src/Monolog/Handler/ElasticsearchHandler.php +++ b/src/Monolog/Handler/ElasticsearchHandler.php @@ -11,6 +11,7 @@ namespace Monolog\Handler; +use Monolog\LevelName; use Throwable; use RuntimeException; use Monolog\Level; @@ -68,7 +69,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler * * @phpstan-param InputOptions $options */ - public function __construct(Client $client, array $options = [], $level = Level::Debug, bool $bubble = true) + public function __construct(Client $client, array $options = [], int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { parent::__construct($level, $bubble); $this->client = $client; diff --git a/src/Monolog/Handler/ErrorLogHandler.php b/src/Monolog/Handler/ErrorLogHandler.php index e19a129f..d52e9260 100644 --- a/src/Monolog/Handler/ErrorLogHandler.php +++ b/src/Monolog/Handler/ErrorLogHandler.php @@ -14,6 +14,7 @@ namespace Monolog\Handler; use Monolog\Formatter\LineFormatter; use Monolog\Formatter\FormatterInterface; use Monolog\Level; +use Monolog\LevelName; use Monolog\Utils; use Monolog\LogRecord; @@ -34,7 +35,7 @@ class ErrorLogHandler extends AbstractProcessingHandler * @param int $messageType Says where the error should go. * @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 = Level::Debug, bool $bubble = true, bool $expandNewlines = false) + public function __construct(int $messageType = self::OPERATING_SYSTEM, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true, bool $expandNewlines = false) { parent::__construct($level, $bubble); diff --git a/src/Monolog/Handler/GelfHandler.php b/src/Monolog/Handler/GelfHandler.php index 6ed79c38..ed35f6d1 100644 --- a/src/Monolog/Handler/GelfHandler.php +++ b/src/Monolog/Handler/GelfHandler.php @@ -15,6 +15,7 @@ use Gelf\PublisherInterface; use Monolog\Level; use Monolog\Formatter\GelfMessageFormatter; use Monolog\Formatter\FormatterInterface; +use Monolog\LevelName; use Monolog\LogRecord; /** @@ -33,7 +34,7 @@ class GelfHandler extends AbstractProcessingHandler /** * @param PublisherInterface $publisher a gelf publisher object */ - public function __construct(PublisherInterface $publisher, $level = Level::Debug, bool $bubble = true) + public function __construct(PublisherInterface $publisher, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { parent::__construct($level, $bubble); diff --git a/src/Monolog/Handler/IFTTTHandler.php b/src/Monolog/Handler/IFTTTHandler.php index 4bbd4d59..bbf28c1d 100644 --- a/src/Monolog/Handler/IFTTTHandler.php +++ b/src/Monolog/Handler/IFTTTHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Level; +use Monolog\LevelName; use Monolog\Utils; use Monolog\LogRecord; @@ -35,7 +36,7 @@ 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 */ - public function __construct(string $eventName, string $secretKey, $level = Level::Error, bool $bubble = true) + public function __construct(string $eventName, string $secretKey, int|string|Level|LevelName $level = Level::Error, bool $bubble = true) { if (!extension_loaded('curl')) { throw new MissingExtensionException('The curl extension is needed to use the IFTTTHandler'); diff --git a/src/Monolog/Handler/LogglyHandler.php b/src/Monolog/Handler/LogglyHandler.php index f0be46ac..51ec6e1a 100644 --- a/src/Monolog/Handler/LogglyHandler.php +++ b/src/Monolog/Handler/LogglyHandler.php @@ -14,6 +14,7 @@ namespace Monolog\Handler; use Monolog\Level; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\LogglyFormatter; +use Monolog\LevelName; use function array_key_exists; use CurlHandle; use Monolog\LogRecord; @@ -48,7 +49,7 @@ class LogglyHandler extends AbstractProcessingHandler * * @throws MissingExtensionException If the curl extension is missing */ - public function __construct(string $token, $level = Level::Debug, bool $bubble = true) + public function __construct(string $token, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { if (!extension_loaded('curl')) { throw new MissingExtensionException('The curl extension is needed to use the LogglyHandler'); diff --git a/src/Monolog/Handler/MandrillHandler.php b/src/Monolog/Handler/MandrillHandler.php index bc8553e1..f1351b50 100644 --- a/src/Monolog/Handler/MandrillHandler.php +++ b/src/Monolog/Handler/MandrillHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Level; +use Monolog\LevelName; use Swift; use Swift_Message; @@ -31,7 +32,7 @@ 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 */ - public function __construct(string $apiKey, callable|Swift_Message $message, $level = Level::Error, bool $bubble = true) + public function __construct(string $apiKey, callable|Swift_Message $message, int|string|Level|LevelName $level = Level::Error, bool $bubble = true) { parent::__construct($level, $bubble); diff --git a/src/Monolog/Handler/MongoDBHandler.php b/src/Monolog/Handler/MongoDBHandler.php index 7461ebc2..7ca9f323 100644 --- a/src/Monolog/Handler/MongoDBHandler.php +++ b/src/Monolog/Handler/MongoDBHandler.php @@ -17,6 +17,7 @@ use MongoDB\Client; use Monolog\Level; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\MongoDBFormatter; +use Monolog\LevelName; use Monolog\LogRecord; /** @@ -47,12 +48,8 @@ class MongoDBHandler extends AbstractProcessingHandler * @param string $database Database name * @param string $collection Collection name */ - public function __construct($mongodb, string $database, string $collection, $level = Level::Debug, bool $bubble = true) + public function __construct(Client|Manager $mongodb, string $database, string $collection, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { - if (!($mongodb instanceof Client || $mongodb instanceof Manager)) { - throw new \InvalidArgumentException('MongoDB\Client or MongoDB\Driver\Manager instance required'); - } - if ($mongodb instanceof Client) { $this->collection = $mongodb->selectCollection($database, $collection); } else { diff --git a/src/Monolog/Handler/NativeMailerHandler.php b/src/Monolog/Handler/NativeMailerHandler.php index 436d93c9..1bd5a0e8 100644 --- a/src/Monolog/Handler/NativeMailerHandler.php +++ b/src/Monolog/Handler/NativeMailerHandler.php @@ -13,6 +13,7 @@ namespace Monolog\Handler; use Monolog\Level; use Monolog\Formatter\LineFormatter; +use Monolog\LevelName; /** * NativeMailerHandler uses the mail() function to send the emails @@ -66,7 +67,7 @@ class NativeMailerHandler extends MailHandler * @param string $from The sender of the mail * @param int $maxColumnWidth The maximum column width that the message lines will have */ - public function __construct($to, string $subject, string $from, $level = Level::Error, bool $bubble = true, int $maxColumnWidth = 70) + public function __construct(string|array $to, string $subject, string $from, int|string|Level|LevelName $level = Level::Error, bool $bubble = true, int $maxColumnWidth = 70) { parent::__construct($level, $bubble); $this->to = (array) $to; diff --git a/src/Monolog/Handler/PHPConsoleHandler.php b/src/Monolog/Handler/PHPConsoleHandler.php index 80e40d20..c2bf2b62 100644 --- a/src/Monolog/Handler/PHPConsoleHandler.php +++ b/src/Monolog/Handler/PHPConsoleHandler.php @@ -14,6 +14,7 @@ namespace Monolog\Handler; use Monolog\Formatter\LineFormatter; use Monolog\Formatter\FormatterInterface; use Monolog\Level; +use Monolog\LevelName; use Monolog\Utils; use PhpConsole\Connector; use PhpConsole\Handler as VendorPhpConsoleHandler; @@ -120,7 +121,7 @@ class PHPConsoleHandler extends AbstractProcessingHandler * @throws \RuntimeException * @phpstan-param InputOptions $options */ - public function __construct(array $options = [], ?Connector $connector = null, $level = Level::Debug, bool $bubble = true) + public function __construct(array $options = [], ?Connector $connector = null, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { if (!class_exists('PhpConsole\Connector')) { throw new \RuntimeException('PHP Console library not found. See https://github.com/barbushin/php-console#installation'); diff --git a/src/Monolog/Handler/ProcessHandler.php b/src/Monolog/Handler/ProcessHandler.php index 57f3cbf2..c6cb654e 100644 --- a/src/Monolog/Handler/ProcessHandler.php +++ b/src/Monolog/Handler/ProcessHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Level; +use Monolog\LevelName; use Monolog\LogRecord; /** @@ -58,7 +59,7 @@ class ProcessHandler extends AbstractProcessingHandler * @param string|null $cwd "Current working directory" (CWD) for the process to be executed in. * @throws \InvalidArgumentException */ - public function __construct(string $command, $level = Level::Debug, bool $bubble = true, ?string $cwd = null) + public function __construct(string $command, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true, ?string $cwd = null) { if ($command === '') { throw new \InvalidArgumentException('The command argument must be a non-empty string.'); diff --git a/src/Monolog/Handler/PsrHandler.php b/src/Monolog/Handler/PsrHandler.php index 2c17a56d..3f1f097f 100644 --- a/src/Monolog/Handler/PsrHandler.php +++ b/src/Monolog/Handler/PsrHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Level; +use Monolog\LevelName; use Psr\Log\LoggerInterface; use Monolog\Formatter\FormatterInterface; use Monolog\LogRecord; @@ -37,7 +38,7 @@ class PsrHandler extends AbstractHandler implements FormattableHandlerInterface /** * @param LoggerInterface $logger The underlying PSR-3 compliant logger to which messages will be proxied */ - public function __construct(LoggerInterface $logger, $level = Level::Debug, bool $bubble = true) + public function __construct(LoggerInterface $logger, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { parent::__construct($level, $bubble); diff --git a/src/Monolog/Handler/RotatingFileHandler.php b/src/Monolog/Handler/RotatingFileHandler.php index c9febeb5..6228d49d 100644 --- a/src/Monolog/Handler/RotatingFileHandler.php +++ b/src/Monolog/Handler/RotatingFileHandler.php @@ -13,6 +13,7 @@ namespace Monolog\Handler; use InvalidArgumentException; use Monolog\Level; +use Monolog\LevelName; use Monolog\Utils; use Monolog\LogRecord; @@ -43,7 +44,7 @@ class RotatingFileHandler extends StreamHandler * @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 */ - public function __construct(string $filename, int $maxFiles = 0, $level = Level::Debug, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false) + public function __construct(string $filename, int $maxFiles = 0, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false) { $this->filename = Utils::canonicalizePath($filename); $this->maxFiles = $maxFiles; diff --git a/src/Monolog/Handler/SendGridHandler.php b/src/Monolog/Handler/SendGridHandler.php index 6752671b..9a6823b1 100644 --- a/src/Monolog/Handler/SendGridHandler.php +++ b/src/Monolog/Handler/SendGridHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Level; +use Monolog\LevelName; /** * SendGridrHandler uses the SendGrid API v2 function to send Log emails, more information in https://sendgrid.com/docs/API_Reference/Web_API/mail.html @@ -53,7 +54,7 @@ class SendGridHandler extends MailHandler * @param string|string[] $to The recipients of the email * @param string $subject The subject of the mail */ - public function __construct(string $apiUser, string $apiKey, string $from, $to, string $subject, $level = Level::Error, bool $bubble = true) + public function __construct(string $apiUser, string $apiKey, string $from, string|array $to, string $subject, int|string|Level|LevelName $level = Level::Error, bool $bubble = true) { if (!extension_loaded('curl')) { throw new MissingExtensionException('The curl extension is needed to use the SendGridHandler'); diff --git a/src/Monolog/Handler/SqsHandler.php b/src/Monolog/Handler/SqsHandler.php index ae91d4a3..83dd8327 100644 --- a/src/Monolog/Handler/SqsHandler.php +++ b/src/Monolog/Handler/SqsHandler.php @@ -13,6 +13,7 @@ namespace Monolog\Handler; use Aws\Sqs\SqsClient; use Monolog\Level; +use Monolog\LevelName; use Monolog\Utils; use Monolog\LogRecord; @@ -31,7 +32,7 @@ class SqsHandler extends AbstractProcessingHandler private SqsClient $client; private string $queueUrl; - public function __construct(SqsClient $sqsClient, string $queueUrl, $level = Level::Debug, bool $bubble = true) + public function __construct(SqsClient $sqsClient, string $queueUrl, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { parent::__construct($level, $bubble); diff --git a/src/Monolog/Handler/StreamHandler.php b/src/Monolog/Handler/StreamHandler.php index 0426868b..099f7fd0 100644 --- a/src/Monolog/Handler/StreamHandler.php +++ b/src/Monolog/Handler/StreamHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Level; +use Monolog\LevelName; use Monolog\Utils; use Monolog\LogRecord; @@ -44,7 +45,7 @@ class StreamHandler extends AbstractProcessingHandler * * @throws \InvalidArgumentException If stream is not a resource or string */ - public function __construct($stream, $level = Level::Debug, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false) + public function __construct($stream, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false) { parent::__construct($level, $bubble); diff --git a/src/Monolog/Handler/SyslogHandler.php b/src/Monolog/Handler/SyslogHandler.php index 02990339..d761f0d9 100644 --- a/src/Monolog/Handler/SyslogHandler.php +++ b/src/Monolog/Handler/SyslogHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Level; +use Monolog\LevelName; use Monolog\Utils; use Monolog\LogRecord; @@ -37,7 +38,7 @@ class SyslogHandler extends AbstractSyslogHandler * @param string|int $facility Either one of the names of the keys in $this->facilities, or a LOG_* facility constant * @param int $logopts Option flags for the openlog() call, defaults to LOG_PID */ - public function __construct(string $ident, $facility = LOG_USER, $level = Level::Debug, bool $bubble = true, int $logopts = LOG_PID) + public function __construct(string $ident, string|int $facility = LOG_USER, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true, int $logopts = LOG_PID) { parent::__construct($facility, $level, $bubble); diff --git a/src/Monolog/Handler/SyslogUdpHandler.php b/src/Monolog/Handler/SyslogUdpHandler.php index a40317d2..a308c2c2 100644 --- a/src/Monolog/Handler/SyslogUdpHandler.php +++ b/src/Monolog/Handler/SyslogUdpHandler.php @@ -14,6 +14,7 @@ namespace Monolog\Handler; use DateTimeInterface; use Monolog\Level; use Monolog\Handler\SyslogUdp\UdpSocket; +use Monolog\LevelName; use Monolog\Utils; use Monolog\LogRecord; @@ -52,7 +53,7 @@ class SyslogUdpHandler extends AbstractSyslogHandler * * @phpstan-param self::RFC* $rfc */ - public function __construct(string $host, int $port = 514, $facility = LOG_USER, $level = Level::Debug, bool $bubble = true, string $ident = 'php', int $rfc = self::RFC5424) + public function __construct(string $host, int $port = 514, string|int $facility = LOG_USER, int|string|Level|LevelName $level = Level::Debug, bool $bubble = true, string $ident = 'php', int $rfc = self::RFC5424) { if (!extension_loaded('sockets')) { throw new MissingExtensionException('The sockets extension is required to use the SyslogUdpHandler'); diff --git a/src/Monolog/Handler/ZendMonitorHandler.php b/src/Monolog/Handler/ZendMonitorHandler.php index 9db02765..791c11f5 100644 --- a/src/Monolog/Handler/ZendMonitorHandler.php +++ b/src/Monolog/Handler/ZendMonitorHandler.php @@ -14,6 +14,7 @@ namespace Monolog\Handler; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\NormalizerFormatter; use Monolog\Level; +use Monolog\LevelName; use Monolog\LogRecord; /** @@ -27,7 +28,7 @@ class ZendMonitorHandler extends AbstractProcessingHandler /** * @throws MissingExtensionException */ - public function __construct($level = Level::Debug, bool $bubble = true) + public function __construct(int|string|Level|LevelName $level = Level::Debug, bool $bubble = true) { if (!function_exists('zend_monitor_custom_event')) { throw new MissingExtensionException( diff --git a/tests/Monolog/Handler/MongoDBHandlerTest.php b/tests/Monolog/Handler/MongoDBHandlerTest.php index 6fbdc5f3..0a518c71 100644 --- a/tests/Monolog/Handler/MongoDBHandlerTest.php +++ b/tests/Monolog/Handler/MongoDBHandlerTest.php @@ -18,7 +18,7 @@ class MongoDBHandlerTest extends TestCase { public function testConstructorShouldThrowExceptionForInvalidMongo() { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(\TypeError::class); new MongoDBHandler(new \stdClass, 'db', 'collection'); }