1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-19 23:56:17 +02:00

Move phpdoc to native types

This commit is contained in:
Jordi Boggiano
2022-04-20 09:21:58 +02:00
parent 2695fa86cd
commit 7952a83e0c
117 changed files with 432 additions and 766 deletions

View File

@@ -21,10 +21,7 @@ use DateTimeZone;
*/ */
class DateTimeImmutable extends \DateTimeImmutable implements \JsonSerializable class DateTimeImmutable extends \DateTimeImmutable implements \JsonSerializable
{ {
/** private bool $useMicroseconds;
* @var bool
*/
private $useMicroseconds;
public function __construct(bool $useMicroseconds, ?DateTimeZone $timezone = null) public function __construct(bool $useMicroseconds, ?DateTimeZone $timezone = null)
{ {

View File

@@ -11,6 +11,7 @@
namespace Monolog; namespace Monolog;
use Closure;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel; use Psr\Log\LogLevel;
@@ -25,31 +26,24 @@ use Psr\Log\LogLevel;
*/ */
class ErrorHandler class ErrorHandler
{ {
/** @var LoggerInterface */ private LoggerInterface $logger;
private $logger;
/** @var ?callable */ private Closure|null $previousExceptionHandler = null;
private $previousExceptionHandler = null;
/** @var array<class-string, LogLevel::*> an array of class name to LogLevel::* constant mapping */ /** @var array<class-string, LogLevel::*> an array of class name to LogLevel::* constant mapping */
private $uncaughtExceptionLevelMap = []; private array $uncaughtExceptionLevelMap = [];
/** @var callable|true|null */ /** @var callable|true|null */
private $previousErrorHandler = null; private $previousErrorHandler = null;
/** @var array<int, LogLevel::*> an array of E_* constant to LogLevel::* constant mapping */ /** @var array<int, LogLevel::*> an array of E_* constant to LogLevel::* constant mapping */
private $errorLevelMap = []; private array $errorLevelMap = [];
/** @var bool */ private bool $handleOnlyReportedErrors = true;
private $handleOnlyReportedErrors = true;
/** @var bool */ private bool $hasFatalErrorHandler = false;
private $hasFatalErrorHandler = false; private string $fatalLevel = LogLevel::ALERT;
/** @var LogLevel::* */ private string|null $reservedMemory = null;
private $fatalLevel = LogLevel::ALERT; /** @var mixed|null */
/** @var ?string */ private $lastFatalTrace = null;
private $reservedMemory = null; private const FATAL_ERRORS = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR];
/** @var ?mixed */
private $lastFatalTrace;
/** @var int[] */
private static $fatalErrors = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR];
public function __construct(LoggerInterface $logger) public function __construct(LoggerInterface $logger)
{ {
@@ -99,7 +93,7 @@ class ErrorHandler
} }
} }
if ($callPrevious && $prev) { if ($callPrevious && $prev) {
$this->previousExceptionHandler = $prev; $this->previousExceptionHandler = $prev(...);
} }
return $this; return $this;
@@ -213,7 +207,7 @@ class ErrorHandler
} }
// fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries // fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries
if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) { if (!$this->hasFatalErrorHandler || !in_array($code, self::FATAL_ERRORS, true)) {
$level = $this->errorLevelMap[$code] ?? LogLevel::CRITICAL; $level = $this->errorLevelMap[$code] ?? LogLevel::CRITICAL;
$this->logger->log($level, self::codeToString($code).': '.$message, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line]); $this->logger->log($level, self::codeToString($code).': '.$message, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line]);
} else { } else {
@@ -239,7 +233,7 @@ class ErrorHandler
$this->reservedMemory = ''; $this->reservedMemory = '';
$lastError = error_get_last(); $lastError = error_get_last();
if ($lastError && in_array($lastError['type'], self::$fatalErrors, true)) { if ($lastError && in_array($lastError['type'], self::FATAL_ERRORS, true)) {
$this->logger->log( $this->logger->log(
$this->fatalLevel, $this->fatalLevel,
'Fatal Error ('.self::codeToString($lastError['type']).'): '.$lastError['message'], 'Fatal Error ('.self::codeToString($lastError['type']).'): '.$lastError['message'],
@@ -254,10 +248,7 @@ class ErrorHandler
} }
} }
/** private static function codeToString(int $code): string
* @param int $code
*/
private static function codeToString($code): string
{ {
return match ($code) { return match ($code) {
E_ERROR => 'E_ERROR', E_ERROR => 'E_ERROR',

View File

@@ -41,7 +41,7 @@ class ChromePHPFormatter implements FormatterInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function format(LogRecord $record) public function format(LogRecord $record)
{ {
@@ -72,7 +72,7 @@ class ChromePHPFormatter implements FormatterInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function formatBatch(array $records) public function formatBatch(array $records)
{ {

View File

@@ -24,7 +24,7 @@ class ElasticaFormatter extends NormalizerFormatter
/** /**
* @var string Elastic search index name * @var string Elastic search index name
*/ */
protected $index; protected string $index;
/** /**
* @var ?string Elastic search document type * @var ?string Elastic search document type
@@ -45,7 +45,7 @@ class ElasticaFormatter extends NormalizerFormatter
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function format(LogRecord $record) public function format(LogRecord $record)
{ {

View File

@@ -24,12 +24,12 @@ class ElasticsearchFormatter extends NormalizerFormatter
/** /**
* @var string Elasticsearch index name * @var string Elasticsearch index name
*/ */
protected $index; protected string $index;
/** /**
* @var string Elasticsearch record type * @var string Elasticsearch record type
*/ */
protected $type; protected string $type;
/** /**
* @param string $index Elasticsearch index name * @param string $index Elasticsearch index name
@@ -45,7 +45,7 @@ class ElasticsearchFormatter extends NormalizerFormatter
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function format(LogRecord $record) public function format(LogRecord $record)
{ {

View File

@@ -20,15 +20,9 @@ use Monolog\LogRecord;
*/ */
class FlowdockFormatter implements FormatterInterface class FlowdockFormatter implements FormatterInterface
{ {
/** private string $source;
* @var string
*/
private $source;
/** private string $sourceEmail;
* @var string
*/
private $sourceEmail;
public function __construct(string $source, string $sourceEmail) public function __construct(string $source, string $sourceEmail)
{ {
@@ -37,7 +31,7 @@ class FlowdockFormatter implements FormatterInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
* *
* @return mixed[] * @return mixed[]
*/ */
@@ -71,7 +65,7 @@ class FlowdockFormatter implements FormatterInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
* *
* @return mixed[][] * @return mixed[][]
*/ */

View File

@@ -40,7 +40,7 @@ class FluentdFormatter implements FormatterInterface
/** /**
* @var bool $levelTag should message level be a part of the fluentd tag * @var bool $levelTag should message level be a part of the fluentd tag
*/ */
protected $levelTag = false; protected bool $levelTag = false;
public function __construct(bool $levelTag = false) public function __construct(bool $levelTag = false)
{ {

View File

@@ -29,22 +29,22 @@ class GelfMessageFormatter extends NormalizerFormatter
/** /**
* @var string the name of the system for the Gelf log message * @var string the name of the system for the Gelf log message
*/ */
protected $systemName; protected string $systemName;
/** /**
* @var string a prefix for 'extra' fields from the Monolog record (optional) * @var string a prefix for 'extra' fields from the Monolog record (optional)
*/ */
protected $extraPrefix; protected string $extraPrefix;
/** /**
* @var string a prefix for 'context' fields from the Monolog record (optional) * @var string a prefix for 'context' fields from the Monolog record (optional)
*/ */
protected $contextPrefix; protected string $contextPrefix;
/** /**
* @var int max length per field * @var int max length per field
*/ */
protected $maxLength; protected int $maxLength;
/** /**
* Translates Monolog log levels to Graylog2 log priorities. * Translates Monolog log levels to Graylog2 log priorities.
@@ -79,7 +79,7 @@ class GelfMessageFormatter extends NormalizerFormatter
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function format(LogRecord $record): Message public function format(LogRecord $record): Message
{ {

View File

@@ -69,7 +69,7 @@ class JsonFormatter extends NormalizerFormatter
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function format(LogRecord $record): string public function format(LogRecord $record): string
{ {
@@ -94,7 +94,7 @@ class JsonFormatter extends NormalizerFormatter
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function formatBatch(array $records): string public function formatBatch(array $records): string
{ {
@@ -104,8 +104,6 @@ class JsonFormatter extends NormalizerFormatter
}; };
} }
/**
*/
public function includeStacktraces(bool $include = true): self public function includeStacktraces(bool $include = true): self
{ {
$this->includeStacktraces = $include; $this->includeStacktraces = $include;
@@ -183,7 +181,7 @@ class JsonFormatter extends NormalizerFormatter
* Normalizes given exception with or without its own stack trace based on * Normalizes given exception with or without its own stack trace based on
* `includeStacktraces` property. * `includeStacktraces` property.
* *
* {@inheritDoc} * @inheritDoc
*/ */
protected function normalizeException(Throwable $e, int $depth = 0): array protected function normalizeException(Throwable $e, int $depth = 0): array
{ {

View File

@@ -26,14 +26,10 @@ class LineFormatter extends NormalizerFormatter
{ {
public const SIMPLE_FORMAT = "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"; public const SIMPLE_FORMAT = "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n";
/** @var string */ protected string $format;
protected $format; protected bool $allowInlineLineBreaks;
/** @var bool */ protected bool $ignoreEmptyContextAndExtra;
protected $allowInlineLineBreaks; protected bool $includeStacktraces;
/** @var bool */
protected $ignoreEmptyContextAndExtra;
/** @var bool */
protected $includeStacktraces;
/** /**
* @param string|null $format The format of the message * @param string|null $format The format of the message
@@ -74,7 +70,7 @@ class LineFormatter extends NormalizerFormatter
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function format(LogRecord $record): string public function format(LogRecord $record): string
{ {

View File

@@ -22,15 +22,9 @@ class LogmaticFormatter extends JsonFormatter
{ {
protected const MARKERS = ["sourcecode", "php"]; protected const MARKERS = ["sourcecode", "php"];
/** protected string $hostname = '';
* @var string
*/
protected $hostname = '';
/** protected string $appname = '';
* @var string
*/
protected $appname = '';
public function setHostname(string $hostname): self public function setHostname(string $hostname): self
{ {

View File

@@ -26,22 +26,22 @@ class LogstashFormatter extends NormalizerFormatter
/** /**
* @var string the name of the system for the Logstash log message, used to fill the @source field * @var string the name of the system for the Logstash log message, used to fill the @source field
*/ */
protected $systemName; protected string $systemName;
/** /**
* @var string an application name for the Logstash log message, used to fill the @type field * @var string an application name for the Logstash log message, used to fill the @type field
*/ */
protected $applicationName; protected string $applicationName;
/** /**
* @var string the key for 'extra' fields from the Monolog record * @var string the key for 'extra' fields from the Monolog record
*/ */
protected $extraKey; protected string $extraKey;
/** /**
* @var string the key for 'context' fields from the Monolog record * @var string the key for 'context' fields from the Monolog record
*/ */
protected $contextKey; protected string $contextKey;
/** /**
* @param string $applicationName The application that sends the data, used as the "type" field of logstash * @param string $applicationName The application that sends the data, used as the "type" field of logstash
@@ -61,7 +61,7 @@ class LogstashFormatter extends NormalizerFormatter
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function format(LogRecord $record): string public function format(LogRecord $record): string
{ {

View File

@@ -23,12 +23,9 @@ use Monolog\LogRecord;
*/ */
class MongoDBFormatter implements FormatterInterface class MongoDBFormatter implements FormatterInterface
{ {
/** @var bool */ private bool $exceptionTraceAsString;
private $exceptionTraceAsString; private int $maxNestingLevel;
/** @var int */ private bool $isLegacyMongoExt;
private $maxNestingLevel;
/** @var bool */
private $isLegacyMongoExt;
/** /**
* @param int $maxNestingLevel 0 means infinite nesting, the $record itself is level 1, $record->context is 2 * @param int $maxNestingLevel 0 means infinite nesting, the $record itself is level 1, $record->context is 2
@@ -43,7 +40,7 @@ class MongoDBFormatter implements FormatterInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
* *
* @return mixed[] * @return mixed[]
*/ */
@@ -56,7 +53,7 @@ class MongoDBFormatter implements FormatterInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
* *
* @return array<mixed[]> * @return array<mixed[]>
*/ */

View File

@@ -25,15 +25,11 @@ class NormalizerFormatter implements FormatterInterface
{ {
public const SIMPLE_DATE = "Y-m-d\TH:i:sP"; public const SIMPLE_DATE = "Y-m-d\TH:i:sP";
/** @var string */ protected string $dateFormat;
protected $dateFormat; protected int $maxNormalizeDepth = 9;
/** @var int */ protected int $maxNormalizeItemCount = 1000;
protected $maxNormalizeDepth = 9;
/** @var int */
protected $maxNormalizeItemCount = 1000;
/** @var int */ private int $jsonEncodeOptions = Utils::DEFAULT_JSON_FLAGS;
private $jsonEncodeOptions = Utils::DEFAULT_JSON_FLAGS;
/** /**
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
@@ -47,7 +43,7 @@ class NormalizerFormatter implements FormatterInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function format(LogRecord $record) public function format(LogRecord $record)
{ {
@@ -65,7 +61,7 @@ class NormalizerFormatter implements FormatterInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function formatBatch(array $records) public function formatBatch(array $records)
{ {
@@ -277,10 +273,7 @@ class NormalizerFormatter implements FormatterInterface
return Utils::jsonEncode($data, $this->jsonEncodeOptions, $ignoreErrors); return Utils::jsonEncode($data, $this->jsonEncodeOptions, $ignoreErrors);
} }
/** protected function formatDate(\DateTimeInterface $date): string
* @return string
*/
protected function formatDate(\DateTimeInterface $date)
{ {
// in case the date format isn't custom then we defer to the custom DateTimeImmutable // in case the date format isn't custom then we defer to the custom DateTimeImmutable
// formatting logic, which will pick the right format based on whether useMicroseconds is on // formatting logic, which will pick the right format based on whether useMicroseconds is on

View File

@@ -22,7 +22,7 @@ use Monolog\LogRecord;
class ScalarFormatter extends NormalizerFormatter class ScalarFormatter extends NormalizerFormatter
{ {
/** /**
* {@inheritDoc} * @inheritDoc
* *
* @phpstan-return array<string, scalar|null> $record * @phpstan-return array<string, scalar|null> $record
*/ */

View File

@@ -54,7 +54,7 @@ class WildfireFormatter extends NormalizerFormatter
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function format(LogRecord $record): string public function format(LogRecord $record): string
{ {
@@ -112,7 +112,7 @@ class WildfireFormatter extends NormalizerFormatter
} }
/** /**
* {@inheritDoc} * @inheritDoc
* *
* @phpstan-return never * @phpstan-return never
*/ */
@@ -122,7 +122,7 @@ class WildfireFormatter extends NormalizerFormatter
} }
/** /**
* {@inheritDoc} * @inheritDoc
* *
* @return null|scalar|array<mixed[]|scalar|null>|object * @return null|scalar|array<mixed[]|scalar|null>|object
*/ */

View File

@@ -26,8 +26,7 @@ use Monolog\LogRecord;
abstract class AbstractHandler extends Handler implements ResettableInterface abstract class AbstractHandler extends Handler implements ResettableInterface
{ {
protected Level $level = Level::Debug; protected Level $level = Level::Debug;
/** @var bool */ protected bool $bubble = true;
protected $bubble = true;
/** /**
* @param int|string|Level|LevelName|LogLevel::* $level The minimum logging level at which this handler will be triggered * @param int|string|Level|LevelName|LogLevel::* $level The minimum logging level at which this handler will be triggered
@@ -42,7 +41,7 @@ abstract class AbstractHandler extends Handler implements ResettableInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function isHandling(LogRecord $record): bool public function isHandling(LogRecord $record): bool
{ {
@@ -96,9 +95,9 @@ abstract class AbstractHandler extends Handler implements ResettableInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function reset() public function reset(): void
{ {
} }
} }

View File

@@ -27,7 +27,7 @@ abstract class AbstractProcessingHandler extends AbstractHandler implements Proc
use FormattableHandlerTrait; use FormattableHandlerTrait;
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handle(LogRecord $record): bool public function handle(LogRecord $record): bool
{ {
@@ -51,10 +51,7 @@ abstract class AbstractProcessingHandler extends AbstractHandler implements Proc
*/ */
abstract protected function write(LogRecord $record): void; abstract protected function write(LogRecord $record): void;
/** public function reset(): void
* @return void
*/
public function reset()
{ {
parent::reset(); parent::reset();

View File

@@ -20,8 +20,7 @@ use Monolog\Formatter\LineFormatter;
*/ */
abstract class AbstractSyslogHandler extends AbstractProcessingHandler abstract class AbstractSyslogHandler extends AbstractProcessingHandler
{ {
/** @var int */ protected int $facility;
protected $facility;
/** /**
* Translates Monolog log levels to syslog log priorities. * Translates Monolog log levels to syslog log priorities.
@@ -44,7 +43,7 @@ abstract class AbstractSyslogHandler extends AbstractProcessingHandler
* List of valid log facility names. * List of valid log facility names.
* @var array<string, int> * @var array<string, int>
*/ */
protected $facilities = [ protected array $facilities = [
'auth' => \LOG_AUTH, 'auth' => \LOG_AUTH,
'authpriv' => \LOG_AUTHPRIV, 'authpriv' => \LOG_AUTHPRIV,
'cron' => \LOG_CRON, 'cron' => \LOG_CRON,
@@ -96,7 +95,7 @@ abstract class AbstractSyslogHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -26,10 +26,7 @@ class AmqpHandler extends AbstractProcessingHandler
*/ */
protected $exchange; protected $exchange;
/** protected string $exchangeName;
* @var string
*/
protected $exchangeName;
/** /**
* @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
@@ -50,7 +47,7 @@ class AmqpHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -77,7 +74,7 @@ class AmqpHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handleBatch(array $records): void public function handleBatch(array $records): void
{ {
@@ -127,7 +124,7 @@ class AmqpHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -37,7 +37,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
protected const FORMAT_UNKNOWN = 'unknown'; protected const FORMAT_UNKNOWN = 'unknown';
/** /**
* {@inheritDoc} * @inheritDoc
* *
* Formatted output may contain some formatting markers to be transferred to `console.log` using the %c format. * Formatted output may contain some formatting markers to be transferred to `console.log` using the %c format.
* *
@@ -51,7 +51,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -91,7 +91,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
self::resetStatic(); self::resetStatic();
} }
public function reset() public function reset(): void
{ {
parent::reset(); parent::reset();

View File

@@ -56,7 +56,7 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handle(LogRecord $record): bool public function handle(LogRecord $record): bool
{ {
@@ -107,7 +107,7 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function close(): void public function close(): void
{ {
@@ -125,7 +125,7 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
$this->buffer = []; $this->buffer = [];
} }
public function reset() public function reset(): void
{ {
$this->flush(); $this->flush();
@@ -139,7 +139,7 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function setFormatter(FormatterInterface $formatter): HandlerInterface public function setFormatter(FormatterInterface $formatter): HandlerInterface
{ {
@@ -153,7 +153,7 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function getFormatter(): FormatterInterface public function getFormatter(): FormatterInterface
{ {

View File

@@ -44,27 +44,23 @@ class ChromePHPHandler extends AbstractProcessingHandler
*/ */
protected const USER_AGENT_REGEX = '{\b(?:Chrome/\d+(?:\.\d+)*|HeadlessChrome|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}'; protected const USER_AGENT_REGEX = '{\b(?:Chrome/\d+(?:\.\d+)*|HeadlessChrome|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}';
/** @var bool */ protected static bool $initialized = false;
protected static $initialized = false;
/** /**
* Tracks whether we sent too much data * Tracks whether we sent too much data
* *
* Chrome limits the headers to 4KB, so when we sent 3KB we stop sending * Chrome limits the headers to 4KB, so when we sent 3KB we stop sending
*
* @var bool
*/ */
protected static $overflowed = false; protected static bool $overflowed = false;
/** @var mixed[] */ /** @var mixed[] */
protected static $json = [ protected static array $json = [
'version' => self::VERSION, 'version' => self::VERSION,
'columns' => ['label', 'log', 'backtrace', 'type'], 'columns' => ['label', 'log', 'backtrace', 'type'],
'rows' => [], 'rows' => [],
]; ];
/** @var bool */ protected static bool $sendHeaders = true;
protected static $sendHeaders = true;
public function __construct($level = Level::Debug, bool $bubble = true) public function __construct($level = Level::Debug, bool $bubble = true)
{ {
@@ -75,7 +71,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handleBatch(array $records): void public function handleBatch(array $records): void
{ {
@@ -102,7 +98,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -24,7 +24,7 @@ use Monolog\LogRecord;
class CouchDBHandler extends AbstractProcessingHandler class CouchDBHandler extends AbstractProcessingHandler
{ {
/** @var mixed[] */ /** @var mixed[] */
private $options; private array $options;
/** /**
* @param mixed[] $options * @param mixed[] $options
@@ -43,7 +43,7 @@ class CouchDBHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -69,7 +69,7 @@ class CouchDBHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -23,18 +23,13 @@ use Monolog\LogRecord;
*/ */
class CubeHandler extends AbstractProcessingHandler class CubeHandler extends AbstractProcessingHandler
{ {
/** @var \Socket|null */ private ?\Socket $udpConnection = null;
private $udpConnection = null; private ?\CurlHandle $httpConnection = null;
/** @var \CurlHandle|null */ private string $scheme;
private $httpConnection = null; private string $host;
/** @var string */ private int $port;
private $scheme;
/** @var string */
private $host;
/** @var int */
private $port;
/** @var string[] */ /** @var string[] */
private $acceptedSchemes = ['http', 'udp']; private array $acceptedSchemes = ['http', 'udp'];
/** /**
* Create a Cube handler * Create a Cube handler
@@ -111,7 +106,7 @@ class CubeHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {

View File

@@ -21,7 +21,7 @@ use CurlHandle;
final class Util final class Util
{ {
/** @var array<int> */ /** @var array<int> */
private static $retriableErrorCodes = [ private static array $retriableErrorCodes = [
CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_RESOLVE_HOST,
CURLE_COULDNT_CONNECT, CURLE_COULDNT_CONNECT,
CURLE_HTTP_NOT_FOUND, CURLE_HTTP_NOT_FOUND,
@@ -37,7 +37,7 @@ final class Util
* @param CurlHandle $ch curl handler * @param CurlHandle $ch curl handler
* @return bool|string @see curl_exec * @return bool|string @see curl_exec
*/ */
public static function execute($ch, int $retries = 5, bool $closeAfterDone = true) public static function execute(CurlHandle $ch, int $retries = 5, bool $closeAfterDone = true)
{ {
while ($retries--) { while ($retries--) {
$curlResponse = curl_exec($ch); $curlResponse = curl_exec($ch);

View File

@@ -39,25 +39,13 @@ use Monolog\LogRecord;
*/ */
class DeduplicationHandler extends BufferHandler class DeduplicationHandler extends BufferHandler
{ {
/** protected string $deduplicationStore;
* @var string
*/
protected $deduplicationStore;
/** protected Level $deduplicationLevel;
* @var Level
*/
protected $deduplicationLevel;
/** protected int $time;
* @var int
*/
protected $time;
/** private bool $gc = false;
* @var bool
*/
private $gc = false;
/** /**
* @param HandlerInterface $handler Handler. * @param HandlerInterface $handler Handler.

View File

@@ -24,8 +24,7 @@ use Monolog\LogRecord;
*/ */
class DoctrineCouchDBHandler extends AbstractProcessingHandler class DoctrineCouchDBHandler extends AbstractProcessingHandler
{ {
/** @var CouchDBClient */ private CouchDBClient $client;
private $client;
public function __construct(CouchDBClient $client, $level = Level::Debug, bool $bubble = true) public function __construct(CouchDBClient $client, $level = Level::Debug, bool $bubble = true)
{ {
@@ -34,7 +33,7 @@ class DoctrineCouchDBHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {

View File

@@ -29,20 +29,11 @@ class DynamoDbHandler extends AbstractProcessingHandler
{ {
public const DATE_FORMAT = 'Y-m-d\TH:i:s.uO'; public const DATE_FORMAT = 'Y-m-d\TH:i:s.uO';
/** protected DynamoDbClient $client;
* @var DynamoDbClient
*/
protected $client;
/** protected string $table;
* @var string
*/
protected $table;
/** protected Marshaler $marshaler;
* @var Marshaler
*/
protected $marshaler;
public function __construct(DynamoDbClient $client, string $table, $level = Level::Debug, bool $bubble = true) public function __construct(DynamoDbClient $client, string $table, $level = Level::Debug, bool $bubble = true)
{ {
@@ -55,7 +46,7 @@ class DynamoDbHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -80,7 +71,7 @@ class DynamoDbHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -37,15 +37,12 @@ use Monolog\LogRecord;
*/ */
class ElasticaHandler extends AbstractProcessingHandler class ElasticaHandler extends AbstractProcessingHandler
{ {
/** protected Client $client;
* @var Client
*/
protected $client;
/** /**
* @var mixed[] Handler config options * @var mixed[] Handler config options
*/ */
protected $options = []; protected array $options = [];
/** /**
* @param Client $client Elastica Client object * @param Client $client Elastica Client object
@@ -66,7 +63,7 @@ class ElasticaHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -74,7 +71,7 @@ class ElasticaHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function setFormatter(FormatterInterface $formatter): HandlerInterface public function setFormatter(FormatterInterface $formatter): HandlerInterface
{ {
@@ -94,7 +91,7 @@ class ElasticaHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {
@@ -102,7 +99,7 @@ class ElasticaHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handleBatch(array $records): void public function handleBatch(array $records): void
{ {

View File

@@ -44,15 +44,12 @@ use Monolog\LogRecord;
*/ */
class ElasticsearchHandler extends AbstractProcessingHandler class ElasticsearchHandler extends AbstractProcessingHandler
{ {
/** protected Client $client;
* @var Client
*/
protected $client;
/** /**
* @var mixed[] Handler config options * @var mixed[] Handler config options
*/ */
protected $options = []; protected array $options = [];
/** /**
* @param Client $client Elasticsearch Client object * @param Client $client Elasticsearch Client object
@@ -73,7 +70,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -81,7 +78,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function setFormatter(FormatterInterface $formatter): HandlerInterface public function setFormatter(FormatterInterface $formatter): HandlerInterface
{ {
@@ -103,7 +100,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {
@@ -111,7 +108,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handleBatch(array $records): void public function handleBatch(array $records): void
{ {

View File

@@ -27,10 +27,8 @@ class ErrorLogHandler extends AbstractProcessingHandler
public const OPERATING_SYSTEM = 0; public const OPERATING_SYSTEM = 0;
public const SAPI = 4; public const SAPI = 4;
/** @var int */ protected int $messageType;
protected $messageType; protected bool $expandNewlines;
/** @var bool */
protected $expandNewlines;
/** /**
* @param int $messageType Says where the error should go. * @param int $messageType Says where the error should go.
@@ -62,7 +60,7 @@ class ErrorLogHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {
@@ -70,7 +68,7 @@ class ErrorLogHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {

View File

@@ -24,7 +24,7 @@ use Monolog\LogRecord;
class FallbackGroupHandler extends GroupHandler class FallbackGroupHandler extends GroupHandler
{ {
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handle(LogRecord $record): bool public function handle(LogRecord $record): bool
{ {
@@ -44,7 +44,7 @@ class FallbackGroupHandler extends GroupHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handleBatch(array $records): void public function handleBatch(array $records): void
{ {

View File

@@ -49,10 +49,8 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
/** /**
* Whether the messages that are handled can bubble up the stack or not * Whether the messages that are handled can bubble up the stack or not
*
* @var bool
*/ */
protected $bubble; protected bool $bubble;
/** /**
* @phpstan-param (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler * @phpstan-param (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler
@@ -109,7 +107,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function isHandling(LogRecord $record): bool public function isHandling(LogRecord $record): bool
{ {
@@ -117,7 +115,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handle(LogRecord $record): bool public function handle(LogRecord $record): bool
{ {
@@ -135,7 +133,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handleBatch(array $records): void public function handleBatch(array $records): void
{ {
@@ -155,10 +153,8 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
* Return the nested handler * Return the nested handler
* *
* If the handler was provided as a factory callable, this will trigger the handler's instantiation. * If the handler was provided as a factory callable, this will trigger the handler's instantiation.
*
* @return HandlerInterface
*/ */
public function getHandler(LogRecord $record = null) public function getHandler(LogRecord $record = null): HandlerInterface
{ {
if (!$this->handler instanceof HandlerInterface) { if (!$this->handler instanceof HandlerInterface) {
$this->handler = ($this->handler)($record, $this); $this->handler = ($this->handler)($record, $this);
@@ -171,7 +167,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function setFormatter(FormatterInterface $formatter): HandlerInterface public function setFormatter(FormatterInterface $formatter): HandlerInterface
{ {
@@ -186,7 +182,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function getFormatter(): FormatterInterface public function getFormatter(): FormatterInterface
{ {
@@ -198,7 +194,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.'); throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.');
} }
public function reset() public function reset(): void
{ {
$this->resetProcessors(); $this->resetProcessors();

View File

@@ -46,19 +46,14 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
* @phpstan-var (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface * @phpstan-var (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface
*/ */
protected $handler; protected $handler;
/** @var ActivationStrategyInterface */ protected ActivationStrategyInterface $activationStrategy;
protected $activationStrategy; protected bool $buffering = true;
/** @var bool */ protected int $bufferSize;
protected $buffering = true;
/** @var int */
protected $bufferSize;
/** @var LogRecord[] */ /** @var LogRecord[] */
protected $buffer = []; protected array $buffer = [];
/** @var bool */ protected bool $stopBuffering;
protected $stopBuffering;
protected Level|null $passthruLevel = null; protected Level|null $passthruLevel = null;
/** @var bool */ protected bool $bubble;
protected $bubble;
/** /**
* @phpstan-param (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler * @phpstan-param (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler
@@ -100,7 +95,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function isHandling(LogRecord $record): bool public function isHandling(LogRecord $record): bool
{ {
@@ -121,7 +116,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handle(LogRecord $record): bool public function handle(LogRecord $record): bool
{ {
@@ -145,7 +140,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function close(): void public function close(): void
{ {
@@ -154,7 +149,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
$this->getHandler()->close(); $this->getHandler()->close();
} }
public function reset() public function reset(): void
{ {
$this->flushBuffer(); $this->flushBuffer();
@@ -199,10 +194,8 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
* Return the nested handler * Return the nested handler
* *
* If the handler was provided as a factory callable, this will trigger the handler's instantiation. * If the handler was provided as a factory callable, this will trigger the handler's instantiation.
*
* @return HandlerInterface
*/ */
public function getHandler(LogRecord $record = null) public function getHandler(LogRecord $record = null): HandlerInterface
{ {
if (!$this->handler instanceof HandlerInterface) { if (!$this->handler instanceof HandlerInterface) {
$this->handler = ($this->handler)($record, $this); $this->handler = ($this->handler)($record, $this);
@@ -215,7 +208,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function setFormatter(FormatterInterface $formatter): HandlerInterface public function setFormatter(FormatterInterface $formatter): HandlerInterface
{ {
@@ -230,7 +223,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function getFormatter(): FormatterInterface public function getFormatter(): FormatterInterface
{ {

View File

@@ -46,18 +46,15 @@ class FirePHPHandler extends AbstractProcessingHandler
/** /**
* Whether or not Wildfire vendor-specific headers have been generated & sent yet * Whether or not Wildfire vendor-specific headers have been generated & sent yet
* @var bool
*/ */
protected static $initialized = false; protected static bool $initialized = false;
/** /**
* Shared static message index between potentially multiple handlers * Shared static message index between potentially multiple handlers
* @var int
*/ */
protected static $messageIndex = 1; protected static int $messageIndex = 1;
/** @var bool */ protected static bool $sendHeaders = true;
protected static $sendHeaders = true;
/** /**
* Base header creation function used by init headers & record headers * Base header creation function used by init headers & record headers
@@ -96,7 +93,7 @@ class FirePHPHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -33,7 +33,7 @@ class FleepHookHandler extends SocketHandler
/** /**
* @var string Webhook token (specifies the conversation where logs are sent) * @var string Webhook token (specifies the conversation where logs are sent)
*/ */
protected $token; protected string $token;
/** /**
* Construct a new Fleep.io Handler. * Construct a new Fleep.io Handler.
@@ -95,7 +95,7 @@ class FleepHookHandler extends SocketHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function generateDataStream(LogRecord $record): string protected function generateDataStream(LogRecord $record): string
{ {

View File

@@ -30,10 +30,7 @@ use Monolog\LogRecord;
*/ */
class FlowdockHandler extends SocketHandler class FlowdockHandler extends SocketHandler
{ {
/** protected string $apiToken;
* @var string
*/
protected $apiToken;
/** /**
* @throws MissingExtensionException if OpenSSL is missing * @throws MissingExtensionException if OpenSSL is missing
@@ -66,7 +63,7 @@ class FlowdockHandler extends SocketHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function setFormatter(FormatterInterface $formatter): HandlerInterface public function setFormatter(FormatterInterface $formatter): HandlerInterface
{ {
@@ -86,7 +83,7 @@ class FlowdockHandler extends SocketHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -96,7 +93,7 @@ class FlowdockHandler extends SocketHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function generateDataStream(LogRecord $record): string protected function generateDataStream(LogRecord $record): string
{ {

View File

@@ -27,7 +27,7 @@ trait FormattableHandlerTrait
protected $formatter; protected $formatter;
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function setFormatter(FormatterInterface $formatter): HandlerInterface public function setFormatter(FormatterInterface $formatter): HandlerInterface
{ {
@@ -37,7 +37,7 @@ trait FormattableHandlerTrait
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function getFormatter(): FormatterInterface public function getFormatter(): FormatterInterface
{ {

View File

@@ -28,7 +28,7 @@ class GelfHandler extends AbstractProcessingHandler
/** /**
* @var PublisherInterface the publisher object that sends the message to the server * @var PublisherInterface the publisher object that sends the message to the server
*/ */
protected $publisher; protected PublisherInterface $publisher;
/** /**
* @param PublisherInterface $publisher a gelf publisher object * @param PublisherInterface $publisher a gelf publisher object
@@ -41,7 +41,7 @@ class GelfHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -49,7 +49,7 @@ class GelfHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -25,9 +25,8 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface, Reset
use ProcessableHandlerTrait; use ProcessableHandlerTrait;
/** @var HandlerInterface[] */ /** @var HandlerInterface[] */
protected $handlers; protected array $handlers;
/** @var bool */ protected bool $bubble;
protected $bubble;
/** /**
* @param HandlerInterface[] $handlers Array of Handlers. * @param HandlerInterface[] $handlers Array of Handlers.
@@ -46,7 +45,7 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface, Reset
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function isHandling(LogRecord $record): bool public function isHandling(LogRecord $record): bool
{ {
@@ -60,7 +59,7 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface, Reset
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handle(LogRecord $record): bool public function handle(LogRecord $record): bool
{ {
@@ -76,7 +75,7 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface, Reset
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handleBatch(array $records): void public function handleBatch(array $records): void
{ {
@@ -93,7 +92,7 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface, Reset
} }
} }
public function reset() public function reset(): void
{ {
$this->resetProcessors(); $this->resetProcessors();
@@ -114,7 +113,7 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface, Reset
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function setFormatter(FormatterInterface $formatter): HandlerInterface public function setFormatter(FormatterInterface $formatter): HandlerInterface
{ {

View File

@@ -19,7 +19,7 @@ namespace Monolog\Handler;
abstract class Handler implements HandlerInterface abstract class Handler implements HandlerInterface
{ {
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handleBatch(array $records): void public function handleBatch(array $records): void
{ {
@@ -29,7 +29,7 @@ abstract class Handler implements HandlerInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function close(): void public function close(): void
{ {

View File

@@ -34,10 +34,7 @@ use Monolog\LogRecord;
*/ */
class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, FormattableHandlerInterface, ResettableInterface class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, FormattableHandlerInterface, ResettableInterface
{ {
/** protected HandlerInterface $handler;
* @var HandlerInterface
*/
protected $handler;
public function __construct(HandlerInterface $handler) public function __construct(HandlerInterface $handler)
{ {
@@ -45,7 +42,7 @@ class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, F
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function isHandling(LogRecord $record): bool public function isHandling(LogRecord $record): bool
{ {
@@ -53,7 +50,7 @@ class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, F
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handle(LogRecord $record): bool public function handle(LogRecord $record): bool
{ {
@@ -61,7 +58,7 @@ class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, F
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handleBatch(array $records): void public function handleBatch(array $records): void
{ {
@@ -69,7 +66,7 @@ class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, F
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function close(): void public function close(): void
{ {
@@ -77,7 +74,7 @@ class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, F
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function pushProcessor(callable $callback): HandlerInterface public function pushProcessor(callable $callback): HandlerInterface
{ {
@@ -91,7 +88,7 @@ class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, F
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function popProcessor(): callable public function popProcessor(): callable
{ {
@@ -103,7 +100,7 @@ class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, F
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function setFormatter(FormatterInterface $formatter): HandlerInterface public function setFormatter(FormatterInterface $formatter): HandlerInterface
{ {
@@ -117,7 +114,7 @@ class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, F
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function getFormatter(): FormatterInterface public function getFormatter(): FormatterInterface
{ {
@@ -128,7 +125,7 @@ class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, F
throw new \LogicException('The wrapped handler does not implement ' . FormattableHandlerInterface::class); throw new \LogicException('The wrapped handler does not implement ' . FormattableHandlerInterface::class);
} }
public function reset() public function reset(): void
{ {
if ($this->handler instanceof ResettableInterface) { if ($this->handler instanceof ResettableInterface) {
$this->handler->reset(); $this->handler->reset();

View File

@@ -28,10 +28,8 @@ use Monolog\LogRecord;
*/ */
class IFTTTHandler extends AbstractProcessingHandler class IFTTTHandler extends AbstractProcessingHandler
{ {
/** @var string */ private string $eventName;
private $eventName; private string $secretKey;
/** @var string */
private $secretKey;
/** /**
* @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
@@ -50,7 +48,7 @@ class IFTTTHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function write(LogRecord $record): void public function write(LogRecord $record): void
{ {

View File

@@ -22,10 +22,7 @@ use Monolog\LogRecord;
*/ */
class InsightOpsHandler extends SocketHandler class InsightOpsHandler extends SocketHandler
{ {
/** protected string $logToken;
* @var string
*/
protected $logToken;
/** /**
* @param string $token Log token supplied by InsightOps * @param string $token Log token supplied by InsightOps
@@ -68,7 +65,7 @@ class InsightOpsHandler extends SocketHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function generateDataStream(LogRecord $record): string protected function generateDataStream(LogRecord $record): string
{ {

View File

@@ -19,10 +19,7 @@ use Monolog\LogRecord;
*/ */
class LogEntriesHandler extends SocketHandler class LogEntriesHandler extends SocketHandler
{ {
/** protected string $logToken;
* @var string
*/
protected $logToken;
/** /**
* @param string $token Log token supplied by LogEntries * @param string $token Log token supplied by LogEntries
@@ -62,7 +59,7 @@ class LogEntriesHandler extends SocketHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function generateDataStream(LogRecord $record): string protected function generateDataStream(LogRecord $record): string
{ {

View File

@@ -36,13 +36,12 @@ class LogglyHandler extends AbstractProcessingHandler
* *
* @var CurlHandle[] * @var CurlHandle[]
*/ */
protected $curlHandlers = []; protected array $curlHandlers = [];
/** @var string */ protected string $token;
protected $token;
/** @var string[] */ /** @var string[] */
protected $tag = []; protected array $tag = [];
/** /**
* @param string $token API token supplied by Loggly * @param string $token API token supplied by Loggly
@@ -62,11 +61,8 @@ class LogglyHandler extends AbstractProcessingHandler
/** /**
* Loads and returns the shared curl handler for the given endpoint. * Loads and returns the shared curl handler for the given endpoint.
*
*
* @return CurlHandle
*/ */
protected function getCurlHandler(string $endpoint) protected function getCurlHandler(string $endpoint): CurlHandle
{ {
if (!array_key_exists($endpoint, $this->curlHandlers)) { if (!array_key_exists($endpoint, $this->curlHandlers)) {
$this->curlHandlers[$endpoint] = $this->loadCurlHandle($endpoint); $this->curlHandlers[$endpoint] = $this->loadCurlHandle($endpoint);
@@ -77,11 +73,8 @@ class LogglyHandler extends AbstractProcessingHandler
/** /**
* Starts a fresh curl session for the given endpoint and returns its handler. * Starts a fresh curl session for the given endpoint and returns its handler.
*
*
* @return CurlHandle
*/ */
private function loadCurlHandle(string $endpoint) private function loadCurlHandle(string $endpoint): CurlHandle
{ {
$url = sprintf("https://%s/%s/%s/", static::HOST, $endpoint, $this->token); $url = sprintf("https://%s/%s/%s/", static::HOST, $endpoint, $this->token);

View File

@@ -21,20 +21,11 @@ use Monolog\LogRecord;
*/ */
class LogmaticHandler extends SocketHandler class LogmaticHandler extends SocketHandler
{ {
/** private string $logToken;
* @var string
*/
private $logToken;
/** private string $hostname;
* @var string
*/
private $hostname;
/** private string $appname;
* @var string
*/
private $appname;
/** /**
* @param string $token Log token supplied by Logmatic. * @param string $token Log token supplied by Logmatic.
@@ -81,7 +72,7 @@ class LogmaticHandler extends SocketHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function generateDataStream(LogRecord $record): string protected function generateDataStream(LogRecord $record): string
{ {
@@ -89,7 +80,7 @@ class LogmaticHandler extends SocketHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -23,7 +23,7 @@ use Monolog\LogRecord;
abstract class MailHandler extends AbstractProcessingHandler abstract class MailHandler extends AbstractProcessingHandler
{ {
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handleBatch(array $records): void public function handleBatch(array $records): void
{ {
@@ -54,7 +54,7 @@ abstract class MailHandler extends AbstractProcessingHandler
abstract protected function send(string $content, array $records): void; abstract protected function send(string $content, array $records): void;
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {

View File

@@ -22,10 +22,8 @@ use Swift_Message;
*/ */
class MandrillHandler extends MailHandler class MandrillHandler extends MailHandler
{ {
/** @var Swift_Message */ protected Swift_Message $message;
protected $message; protected string $apiKey;
/** @var string */
protected $apiKey;
/** /**
* @phpstan-param (Swift_Message|callable(): Swift_Message) $message * @phpstan-param (Swift_Message|callable(): Swift_Message) $message
@@ -48,7 +46,7 @@ class MandrillHandler extends MailHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function send(string $content, array $records): void protected function send(string $content, array $records): void
{ {

View File

@@ -77,7 +77,7 @@ class MongoDBHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -26,43 +26,39 @@ class NativeMailerHandler extends MailHandler
* The email addresses to which the message will be sent * The email addresses to which the message will be sent
* @var string[] * @var string[]
*/ */
protected $to; protected array $to;
/** /**
* The subject of the email * The subject of the email
* @var string
*/ */
protected $subject; protected string $subject;
/** /**
* Optional headers for the message * Optional headers for the message
* @var string[] * @var string[]
*/ */
protected $headers = []; protected array $headers = [];
/** /**
* Optional parameters for the message * Optional parameters for the message
* @var string[] * @var string[]
*/ */
protected $parameters = []; protected array $parameters = [];
/** /**
* The wordwrap length for the message * The wordwrap length for the message
* @var int
*/ */
protected $maxColumnWidth; protected int $maxColumnWidth;
/** /**
* The Content-type for the message * The Content-type for the message
* @var string|null
*/ */
protected $contentType; protected string|null $contentType = null;
/** /**
* The encoding for the message * The encoding for the message
* @var string
*/ */
protected $encoding = 'utf-8'; protected string $encoding = 'utf-8';
/** /**
* @param string|string[] $to The receiver of the mail * @param string|string[] $to The receiver of the mail
@@ -109,7 +105,7 @@ class NativeMailerHandler extends MailHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function send(string $content, array $records): void protected function send(string $content, array $records): void
{ {

View File

@@ -45,13 +45,11 @@ class NewRelicHandler extends AbstractProcessingHandler
/** /**
* Some context and extra data is passed into the handler as arrays of values. Do we send them as is * Some context and extra data is passed into the handler as arrays of values. Do we send them as is
* (useful if we are using the API), or explode them for display on the NewRelic RPM website? * (useful if we are using the API), or explode them for display on the NewRelic RPM website?
*
* @var bool
*/ */
protected $explodeArrays; protected bool $explodeArrays;
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function __construct( public function __construct(
$level = Level::Error, $level = Level::Error,
@@ -68,7 +66,7 @@ class NewRelicHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -184,7 +182,7 @@ class NewRelicHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -25,7 +25,7 @@ use Monolog\LogRecord;
class NoopHandler extends Handler class NoopHandler extends Handler
{ {
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function isHandling(LogRecord $record): bool public function isHandling(LogRecord $record): bool
{ {
@@ -33,7 +33,7 @@ class NoopHandler extends Handler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handle(LogRecord $record): bool public function handle(LogRecord $record): bool
{ {

View File

@@ -40,7 +40,7 @@ class NullHandler extends Handler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function isHandling(LogRecord $record): bool public function isHandling(LogRecord $record): bool
{ {
@@ -48,7 +48,7 @@ class NullHandler extends Handler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handle(LogRecord $record): bool public function handle(LogRecord $record): bool
{ {

View File

@@ -37,18 +37,17 @@ use Monolog\LogRecord;
*/ */
class OverflowHandler extends AbstractHandler implements FormattableHandlerInterface class OverflowHandler extends AbstractHandler implements FormattableHandlerInterface
{ {
/** @var HandlerInterface */ private HandlerInterface $handler;
private $handler;
/** @var array<int, int> */ /** @var array<int, int> */
private $thresholdMap = []; private array $thresholdMap = [];
/** /**
* Buffer of all messages passed to the handler before the threshold was reached * Buffer of all messages passed to the handler before the threshold was reached
* *
* @var mixed[][] * @var mixed[][]
*/ */
private $buffer = []; private array $buffer = [];
/** /**
* @param array<int, int> $thresholdMap Dictionary of log level value => threshold * @param array<int, int> $thresholdMap Dictionary of log level value => threshold
@@ -76,7 +75,7 @@ class OverflowHandler extends AbstractHandler implements FormattableHandlerInter
* Unless the bubbling is interrupted (by returning true), the Logger class will keep on * Unless the bubbling is interrupted (by returning true), the Logger class will keep on
* calling further handlers in the stack with a given log record. * calling further handlers in the stack with a given log record.
* *
* {@inheritDoc} * @inheritDoc
*/ */
public function handle(LogRecord $record): bool public function handle(LogRecord $record): bool
{ {
@@ -113,7 +112,7 @@ class OverflowHandler extends AbstractHandler implements FormattableHandlerInter
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function setFormatter(FormatterInterface $formatter): HandlerInterface public function setFormatter(FormatterInterface $formatter): HandlerInterface
{ {
@@ -127,7 +126,7 @@ class OverflowHandler extends AbstractHandler implements FormattableHandlerInter
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function getFormatter(): FormatterInterface public function getFormatter(): FormatterInterface
{ {

View File

@@ -42,7 +42,7 @@ use Monolog\LogRecord;
class PHPConsoleHandler extends AbstractProcessingHandler class PHPConsoleHandler extends AbstractProcessingHandler
{ {
/** @var array<string, mixed> */ /** @var array<string, mixed> */
private $options = [ private array $options = [
'enabled' => true, // bool Is PHP Console server enabled 'enabled' => true, // bool Is PHP Console server enabled
'classesPartialsTraceIgnore' => ['Monolog\\'], // array Hide calls of classes started with... 'classesPartialsTraceIgnore' => ['Monolog\\'], // array Hide calls of classes started with...
'debugTagsKeysInContext' => [0, 'tag'], // bool Is PHP Console server enabled 'debugTagsKeysInContext' => [0, 'tag'], // bool Is PHP Console server enabled
@@ -65,8 +65,7 @@ class PHPConsoleHandler extends AbstractProcessingHandler
'dataStorage' => null, // \PhpConsole\Storage|null Fixes problem with custom $_SESSION handler(see http://goo.gl/Ne8juJ) 'dataStorage' => null, // \PhpConsole\Storage|null Fixes problem with custom $_SESSION handler(see http://goo.gl/Ne8juJ)
]; ];
/** @var Connector */ private Connector $connector;
private $connector;
/** /**
* @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
@@ -243,7 +242,7 @@ class PHPConsoleHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -34,20 +34,14 @@ class ProcessHandler extends AbstractProcessingHandler
*/ */
private $process; private $process;
/** private string $command;
* @var string
*/
private $command;
/** private ?string $cwd;
* @var string|null
*/
private $cwd;
/** /**
* @var resource[] * @var resource[]
*/ */
private $pipes = []; private array $pipes = [];
/** /**
* @var array<int, string[]> * @var array<int, string[]>
@@ -177,7 +171,7 @@ class ProcessHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function close(): void public function close(): void
{ {

View File

@@ -26,10 +26,10 @@ trait ProcessableHandlerTrait
* @var callable[] * @var callable[]
* @phpstan-var array<(callable(LogRecord): LogRecord)|ProcessorInterface> * @phpstan-var array<(callable(LogRecord): LogRecord)|ProcessorInterface>
*/ */
protected $processors = []; protected array $processors = [];
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function pushProcessor(callable $callback): HandlerInterface public function pushProcessor(callable $callback): HandlerInterface
{ {
@@ -39,7 +39,7 @@ trait ProcessableHandlerTrait
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function popProcessor(): callable public function popProcessor(): callable
{ {

View File

@@ -29,15 +29,10 @@ class PsrHandler extends AbstractHandler implements FormattableHandlerInterface
{ {
/** /**
* PSR-3 compliant logger * PSR-3 compliant logger
*
* @var LoggerInterface
*/ */
protected $logger; protected LoggerInterface $logger;
/** protected FormatterInterface|null $formatter = null;
* @var FormatterInterface|null
*/
protected $formatter;
/** /**
* @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
@@ -50,7 +45,7 @@ class PsrHandler extends AbstractHandler implements FormattableHandlerInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handle(LogRecord $record): bool public function handle(LogRecord $record): bool
{ {

View File

@@ -26,30 +26,25 @@ use Monolog\LogRecord;
*/ */
class PushoverHandler extends SocketHandler class PushoverHandler extends SocketHandler
{ {
/** @var string */ private string $token;
private $token;
/** @var array<int|string> */ /** @var array<int|string> */
private $users; private array $users;
/** @var string */ private string $title;
private $title;
/** @var string|int|null */ /** @var string|int|null */
private $user = null; private $user = null;
/** @var int */ private int $retry;
private $retry; private int $expire;
/** @var int */
private $expire;
private Level $highPriorityLevel; private Level $highPriorityLevel;
private Level $emergencyLevel; private Level $emergencyLevel;
/** @var bool */ private bool $useFormattedMessage = false;
private $useFormattedMessage = false;
/** /**
* All parameters that can be sent to Pushover * All parameters that can be sent to Pushover
* @see https://pushover.net/api * @see https://pushover.net/api
* @var array<string, bool> * @var array<string, bool>
*/ */
private $parameterNames = [ private array $parameterNames = [
'token' => true, 'token' => true,
'user' => true, 'user' => true,
'message' => true, 'message' => true,
@@ -70,7 +65,7 @@ class PushoverHandler extends SocketHandler
* @see https://pushover.net/api#sounds * @see https://pushover.net/api#sounds
* @var string[] * @var string[]
*/ */
private $sounds = [ private array $sounds = [
'pushover', 'bike', 'bugle', 'cashregister', 'classical', 'cosmic', 'falling', 'gamelan', 'incoming', 'pushover', 'bike', 'bugle', 'cashregister', 'classical', 'cosmic', 'falling', 'gamelan', 'incoming',
'intermission', 'magic', 'mechanical', 'pianobar', 'siren', 'spacealarm', 'tugboat', 'alien', 'climb', 'intermission', 'magic', 'mechanical', 'pianobar', 'siren', 'spacealarm', 'tugboat', 'alien', 'climb',
'persistent', 'echo', 'updown', 'none', 'persistent', 'echo', 'updown', 'none',

View File

@@ -31,10 +31,8 @@ class RedisHandler extends AbstractProcessingHandler
{ {
/** @var \Predis\Client<\Predis\Client>|\Redis */ /** @var \Predis\Client<\Predis\Client>|\Redis */
private $redisClient; private $redisClient;
/** @var string */ private string $redisKey;
private $redisKey; protected int $capSize;
/** @var int */
protected $capSize;
/** /**
* @param \Predis\Client<\Predis\Client>|\Redis $redis The redis instance * @param \Predis\Client<\Predis\Client>|\Redis $redis The redis instance
@@ -55,7 +53,7 @@ class RedisHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -89,7 +87,7 @@ class RedisHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -31,8 +31,7 @@ class RedisPubSubHandler extends AbstractProcessingHandler
{ {
/** @var \Predis\Client<\Predis\Client>|\Redis */ /** @var \Predis\Client<\Predis\Client>|\Redis */
private $redisClient; private $redisClient;
/** @var string */ private string $channelKey;
private $channelKey;
/** /**
* @param \Predis\Client<\Predis\Client>|\Redis $redis The redis instance * @param \Predis\Client<\Predis\Client>|\Redis $redis The redis instance
@@ -51,7 +50,7 @@ class RedisPubSubHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -59,7 +58,7 @@ class RedisPubSubHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function getDefaultFormatter(): FormatterInterface protected function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -35,20 +35,14 @@ use Monolog\LogRecord;
*/ */
class RollbarHandler extends AbstractProcessingHandler class RollbarHandler extends AbstractProcessingHandler
{ {
/** protected RollbarLogger $rollbarLogger;
* @var RollbarLogger
*/
protected $rollbarLogger;
/** /**
* Records whether any log records have been added since the last flush of the rollbar notifier * Records whether any log records have been added since the last flush of the rollbar notifier
*
* @var bool
*/ */
private $hasRecords = false; private bool $hasRecords = false;
/** @var bool */ protected bool $initialized = false;
protected $initialized = false;
/** /**
* @param RollbarLogger $rollbarLogger RollbarLogger object constructed with valid token * @param RollbarLogger $rollbarLogger RollbarLogger object constructed with valid token
@@ -80,7 +74,7 @@ class RollbarHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -121,7 +115,7 @@ class RollbarHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function close(): void public function close(): void
{ {
@@ -129,9 +123,9 @@ class RollbarHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function reset() public function reset(): void
{ {
$this->flush(); $this->flush();

View File

@@ -31,18 +31,12 @@ class RotatingFileHandler extends StreamHandler
public const FILE_PER_MONTH = 'Y-m'; public const FILE_PER_MONTH = 'Y-m';
public const FILE_PER_YEAR = 'Y'; public const FILE_PER_YEAR = 'Y';
/** @var string */ protected string $filename;
protected $filename; protected int $maxFiles;
/** @var int */ protected bool|null $mustRotate = null;
protected $maxFiles; protected \DateTimeImmutable $nextRotation;
/** @var bool */ protected string $filenameFormat;
protected $mustRotate; protected string $dateFormat;
/** @var \DateTimeImmutable */
protected $nextRotation;
/** @var string */
protected $filenameFormat;
/** @var string */
protected $dateFormat;
/** /**
* @param int $maxFiles The maximal amount of files to keep (0 means unlimited) * @param int $maxFiles The maximal amount of files to keep (0 means unlimited)
@@ -61,7 +55,7 @@ class RotatingFileHandler extends StreamHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function close(): void public function close(): void
{ {
@@ -73,9 +67,9 @@ class RotatingFileHandler extends StreamHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function reset() public function reset(): void
{ {
parent::reset(); parent::reset();
@@ -108,7 +102,7 @@ class RotatingFileHandler extends StreamHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {

View File

@@ -38,10 +38,7 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
*/ */
protected $handler; protected $handler;
/** protected int $factor;
* @var int $factor
*/
protected $factor;
/** /**
* @phpstan-param (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler * @phpstan-param (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler
@@ -82,10 +79,8 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
* Return the nested handler * Return the nested handler
* *
* If the handler was provided as a factory callable, this will trigger the handler's instantiation. * If the handler was provided as a factory callable, this will trigger the handler's instantiation.
*
* @return HandlerInterface
*/ */
public function getHandler(LogRecord $record = null) public function getHandler(LogRecord $record = null): HandlerInterface
{ {
if (!$this->handler instanceof HandlerInterface) { if (!$this->handler instanceof HandlerInterface) {
$this->handler = ($this->handler)($record, $this); $this->handler = ($this->handler)($record, $this);
@@ -98,7 +93,7 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function setFormatter(FormatterInterface $formatter): HandlerInterface public function setFormatter(FormatterInterface $formatter): HandlerInterface
{ {
@@ -113,7 +108,7 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function getFormatter(): FormatterInterface public function getFormatter(): FormatterInterface
{ {

View File

@@ -22,33 +22,29 @@ class SendGridHandler extends MailHandler
{ {
/** /**
* The SendGrid API User * The SendGrid API User
* @var string
*/ */
protected $apiUser; protected string $apiUser;
/** /**
* The SendGrid API Key * The SendGrid API Key
* @var string
*/ */
protected $apiKey; protected string $apiKey;
/** /**
* The email addresses to which the message will be sent * The email addresses to which the message will be sent
* @var string
*/ */
protected $from; protected string $from;
/** /**
* The email addresses to which the message will be sent * The email addresses to which the message will be sent
* @var string[] * @var string[]
*/ */
protected $to; protected array $to;
/** /**
* The subject of the email * The subject of the email
* @var string
*/ */
protected $subject; protected string $subject;
/** /**
* @param string $apiUser The SendGrid API User * @param string $apiUser The SendGrid API User
@@ -72,7 +68,7 @@ class SendGridHandler extends MailHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function send(string $content, array $records): void protected function send(string $content, array $records): void
{ {

View File

@@ -37,55 +37,46 @@ class SlackRecord
/** /**
* Slack channel (encoded ID or name) * Slack channel (encoded ID or name)
* @var string|null
*/ */
private $channel; private ?string $channel;
/** /**
* Name of a bot * Name of a bot
* @var string|null
*/ */
private $username; private ?string $username;
/** /**
* User icon e.g. 'ghost', 'http://example.com/user.png' * User icon e.g. 'ghost', 'http://example.com/user.png'
* @var string|null
*/ */
private $userIcon; private ?string $userIcon;
/** /**
* Whether the message should be added to Slack as attachment (plain text otherwise) * Whether the message should be added to Slack as attachment (plain text otherwise)
* @var bool
*/ */
private $useAttachment; private bool $useAttachment;
/** /**
* Whether the the context/extra messages added to Slack as attachments are in a short style * Whether the the context/extra messages added to Slack as attachments are in a short style
* @var bool
*/ */
private $useShortAttachment; private bool $useShortAttachment;
/** /**
* Whether the attachment should include context and extra data * Whether the attachment should include context and extra data
* @var bool
*/ */
private $includeContextAndExtra; private bool $includeContextAndExtra;
/** /**
* Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2'] * Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2']
* @var string[] * @var string[]
*/ */
private $excludeFields; private array $excludeFields;
/** /**
* @var ?FormatterInterface * @var ?FormatterInterface
*/ */
private $formatter; private $formatter;
/** private NormalizerFormatter $normalizerFormatter;
* @var NormalizerFormatter
*/
private $normalizerFormatter;
/** /**
* @param string[] $excludeFields * @param string[] $excludeFields

View File

@@ -27,15 +27,13 @@ class SlackHandler extends SocketHandler
{ {
/** /**
* Slack API token * Slack API token
* @var string
*/ */
private $token; private string $token;
/** /**
* Instance of the SlackRecord util class preparing data for Slack API. * Instance of the SlackRecord util class preparing data for Slack API.
* @var SlackRecord
*/ */
private $slackRecord; private SlackRecord $slackRecord;
/** /**
* @param string $token Slack API token * @param string $token Slack API token
@@ -104,7 +102,7 @@ class SlackHandler extends SocketHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function generateDataStream(LogRecord $record): string protected function generateDataStream(LogRecord $record): string
{ {
@@ -153,7 +151,7 @@ class SlackHandler extends SocketHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {

View File

@@ -27,15 +27,13 @@ class SlackWebhookHandler extends AbstractProcessingHandler
{ {
/** /**
* Slack Webhook token * Slack Webhook token
* @var string
*/ */
private $webhookUrl; private string $webhookUrl;
/** /**
* Instance of the SlackRecord util class preparing data for Slack API. * Instance of the SlackRecord util class preparing data for Slack API.
* @var SlackRecord
*/ */
private $slackRecord; private SlackRecord $slackRecord;
/** /**
* @param string $webhookUrl Slack Webhook URL * @param string $webhookUrl Slack Webhook URL
@@ -89,7 +87,7 @@ class SlackWebhookHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {

View File

@@ -22,22 +22,17 @@ use Monolog\LogRecord;
*/ */
class SocketHandler extends AbstractProcessingHandler class SocketHandler extends AbstractProcessingHandler
{ {
/** @var string */ private string $connectionString;
private $connectionString; private float $connectionTimeout;
/** @var float */
private $connectionTimeout;
/** @var resource|null */ /** @var resource|null */
private $resource; private $resource;
/** @var float */ private float $timeout;
private $timeout; private float $writingTimeout;
/** @var float */
private $writingTimeout;
/** @var ?int */ /** @var ?int */
private $lastSentBytes = null; private $lastSentBytes = null;
/** @var ?int */ /** @var ?int */
private $chunkSize; private $chunkSize;
/** @var bool */ private bool $persistent;
private $persistent;
/** @var ?int */ /** @var ?int */
private $errno = null; private $errno = null;
/** @var ?string */ /** @var ?string */
@@ -85,7 +80,7 @@ class SocketHandler extends AbstractProcessingHandler
/** /**
* Connect (if necessary) and write to the socket * Connect (if necessary) and write to the socket
* *
* {@inheritDoc} * @inheritDoc
* *
* @throws \UnexpectedValueException * @throws \UnexpectedValueException
* @throws \RuntimeException * @throws \RuntimeException
@@ -260,10 +255,8 @@ class SocketHandler extends AbstractProcessingHandler
* Wrapper to allow mocking * Wrapper to allow mocking
* *
* @see http://php.net/manual/en/function.stream-set-timeout.php * @see http://php.net/manual/en/function.stream-set-timeout.php
*
* @return bool
*/ */
protected function streamSetTimeout() protected function streamSetTimeout(): bool
{ {
$seconds = floor($this->timeout); $seconds = floor($this->timeout);
$microseconds = round(($this->timeout - $seconds) * 1e6); $microseconds = round(($this->timeout - $seconds) * 1e6);

View File

@@ -28,10 +28,8 @@ class SqsHandler extends AbstractProcessingHandler
/** 100 KB in bytes - head message size for new error log */ /** 100 KB in bytes - head message size for new error log */
protected const HEAD_MESSAGE_SIZE = 102400; protected const HEAD_MESSAGE_SIZE = 102400;
/** @var SqsClient */ private SqsClient $client;
private $client; private string $queueUrl;
/** @var string */
private $queueUrl;
public function __construct(SqsClient $sqsClient, string $queueUrl, $level = Level::Debug, bool $bubble = true) public function __construct(SqsClient $sqsClient, string $queueUrl, $level = Level::Debug, bool $bubble = true)
{ {
@@ -42,7 +40,7 @@ class SqsHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {

View File

@@ -28,8 +28,7 @@ class StreamHandler extends AbstractProcessingHandler
protected const MAX_CHUNK_SIZE = 2147483647; protected const MAX_CHUNK_SIZE = 2147483647;
/** @const int 10MB */ /** @const int 10MB */
protected const DEFAULT_CHUNK_SIZE = 10 * 1024 * 1024; protected const DEFAULT_CHUNK_SIZE = 10 * 1024 * 1024;
/** @var int */ protected int $streamChunkSize;
protected $streamChunkSize;
/** @var resource|null */ /** @var resource|null */
protected $stream; protected $stream;
/** @var ?string */ /** @var ?string */
@@ -38,10 +37,9 @@ class StreamHandler extends AbstractProcessingHandler
private $errorMessage = null; private $errorMessage = null;
/** @var ?int */ /** @var ?int */
protected $filePermission; protected $filePermission;
/** @var bool */ protected bool $useLocking;
protected $useLocking;
/** @var true|null */ /** @var true|null */
private $dirCreated = null; private ?bool $dirCreated = null;
/** /**
* @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
@@ -82,7 +80,7 @@ class StreamHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function close(): void public function close(): void
{ {
@@ -111,15 +109,13 @@ class StreamHandler extends AbstractProcessingHandler
return $this->url; return $this->url;
} }
/**
*/
public function getStreamChunkSize(): int public function getStreamChunkSize(): int
{ {
return $this->streamChunkSize; return $this->streamChunkSize;
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {

View File

@@ -30,10 +30,8 @@ use Monolog\LogRecord;
*/ */
class SyslogHandler extends AbstractSyslogHandler class SyslogHandler extends AbstractSyslogHandler
{ {
/** @var string */ protected string $ident;
protected $ident; protected int $logopts;
/** @var int */
protected $logopts;
/** /**
* @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
@@ -48,7 +46,7 @@ class SyslogHandler extends AbstractSyslogHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function close(): void public function close(): void
{ {
@@ -56,7 +54,7 @@ class SyslogHandler extends AbstractSyslogHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {

View File

@@ -18,12 +18,9 @@ class UdpSocket
{ {
protected const DATAGRAM_MAX_LENGTH = 65023; protected const DATAGRAM_MAX_LENGTH = 65023;
/** @var string */ protected string $ip;
protected $ip; protected int $port;
/** @var int */ protected ?Socket $socket;
protected $port;
/** @var Socket|null */
protected $socket;
public function __construct(string $ip, int $port = 514) public function __construct(string $ip, int $port = 514)
{ {
@@ -39,12 +36,7 @@ class UdpSocket
$this->socket = socket_create($domain, SOCK_DGRAM, $protocol) ?: null; $this->socket = socket_create($domain, SOCK_DGRAM, $protocol) ?: null;
} }
/** public function write(string $line, string $header = ""): void
* @param string $line
* @param string $header
* @return void
*/
public function write($line, $header = "")
{ {
$this->send($this->assembleMessage($line, $header)); $this->send($this->assembleMessage($line, $header));
} }

View File

@@ -30,16 +30,14 @@ class SyslogUdpHandler extends AbstractSyslogHandler
const RFC5424e = 2; const RFC5424e = 2;
/** @var array<self::RFC*, string> */ /** @var array<self::RFC*, string> */
private $dateFormats = [ private array $dateFormats = [
self::RFC3164 => 'M d H:i:s', self::RFC3164 => 'M d H:i:s',
self::RFC5424 => \DateTime::RFC3339, self::RFC5424 => \DateTime::RFC3339,
self::RFC5424e => \DateTime::RFC3339_EXTENDED, self::RFC5424e => \DateTime::RFC3339_EXTENDED,
]; ];
/** @var UdpSocket */ protected UdpSocket $socket;
protected $socket; protected string $ident;
/** @var string */
protected $ident;
/** @var self::RFC* */ /** @var self::RFC* */
protected $rfc; protected $rfc;

View File

@@ -51,16 +51,14 @@ class TelegramBotHandler extends AbstractProcessingHandler
/** /**
* Telegram bot access token provided by BotFather. * Telegram bot access token provided by BotFather.
* Create telegram bot with https://telegram.me/BotFather and use access token from it. * Create telegram bot with https://telegram.me/BotFather and use access token from it.
* @var string
*/ */
private $apiKey; private string $apiKey;
/** /**
* Telegram channel name. * Telegram channel name.
* Since to start with '@' symbol as prefix. * Since to start with '@' symbol as prefix.
* @var string
*/ */
private $channel; private string $channel;
/** /**
* The kind of formatting that is used for the message. * The kind of formatting that is used for the message.
@@ -85,15 +83,13 @@ class TelegramBotHandler extends AbstractProcessingHandler
/** /**
* True - split a message longer than MAX_MESSAGE_LENGTH into parts and send in multiple messages. * True - split a message longer than MAX_MESSAGE_LENGTH into parts and send in multiple messages.
* False - truncates a message that is too long. * False - truncates a message that is too long.
* @var bool
*/ */
private $splitLongMessages; private bool $splitLongMessages;
/** /**
* Adds 1-second delay between sending a split message (according to Telegram API to avoid 429 Too Many Requests). * Adds 1-second delay between sending a split message (according to Telegram API to avoid 429 Too Many Requests).
* @var bool
*/ */
private $delayBetweenMessages; private bool $delayBetweenMessages;
/** /**
* @param string $apiKey Telegram bot access token provided by BotFather * @param string $apiKey Telegram bot access token provided by BotFather
@@ -177,7 +173,7 @@ class TelegramBotHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handleBatch(array $records): void public function handleBatch(array $records): void
{ {

View File

@@ -72,43 +72,33 @@ use Monolog\LogRecord;
class TestHandler extends AbstractProcessingHandler class TestHandler extends AbstractProcessingHandler
{ {
/** @var LogRecord[] */ /** @var LogRecord[] */
protected $records = []; protected array $records = [];
/** @phpstan-var array<value-of<Level::VALUES>, LogRecord[]> */ /** @phpstan-var array<value-of<Level::VALUES>, LogRecord[]> */
protected array $recordsByLevel = []; protected array $recordsByLevel = [];
/** @var bool */ private bool $skipReset = false;
private $skipReset = false;
/** /**
* @return array<LogRecord> * @return array<LogRecord>
*/ */
public function getRecords() public function getRecords(): array
{ {
return $this->records; return $this->records;
} }
/** public function clear(): void
* @return void
*/
public function clear()
{ {
$this->records = []; $this->records = [];
$this->recordsByLevel = []; $this->recordsByLevel = [];
} }
/** public function reset(): void
* @return void
*/
public function reset()
{ {
if (!$this->skipReset) { if (!$this->skipReset) {
$this->clear(); $this->clear();
} }
} }
/** public function setSkipReset(bool $skipReset): void
* @return void
*/
public function setSkipReset(bool $skipReset)
{ {
$this->skipReset = $skipReset; $this->skipReset = $skipReset;
} }
@@ -177,7 +167,7 @@ class TestHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -186,11 +176,9 @@ class TestHandler extends AbstractProcessingHandler
} }
/** /**
* @param string $method
* @param mixed[] $args * @param mixed[] $args
* @return bool
*/ */
public function __call($method, $args) public function __call(string $method, array $args): bool
{ {
if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
$genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3]; $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];

View File

@@ -23,7 +23,7 @@ use Throwable;
class WhatFailureGroupHandler extends GroupHandler class WhatFailureGroupHandler extends GroupHandler
{ {
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handle(LogRecord $record): bool public function handle(LogRecord $record): bool
{ {
@@ -43,7 +43,7 @@ class WhatFailureGroupHandler extends GroupHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function handleBatch(array $records): void public function handleBatch(array $records): void
{ {

View File

@@ -56,7 +56,7 @@ class ZendMonitorHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
protected function write(LogRecord $record): void protected function write(LogRecord $record): void
{ {
@@ -81,7 +81,7 @@ class ZendMonitorHandler extends AbstractProcessingHandler
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function getDefaultFormatter(): FormatterInterface public function getDefaultFormatter(): FormatterInterface
{ {

View File

@@ -106,17 +106,14 @@ class Logger implements LoggerInterface, ResettableInterface
*/ */
public const API = 3; public const API = 3;
/** protected string $name;
* @var string
*/
protected $name;
/** /**
* The handler stack * The handler stack
* *
* @var HandlerInterface[] * @var HandlerInterface[]
*/ */
protected $handlers; protected array $handlers;
/** /**
* Processors that will process all log records * Processors that will process all log records
@@ -127,15 +124,9 @@ class Logger implements LoggerInterface, ResettableInterface
*/ */
protected $processors; protected $processors;
/** protected bool $microsecondTimestamps = true;
* @var bool
*/
protected $microsecondTimestamps = true;
/** protected DateTimeZone $timezone;
* @var DateTimeZone
*/
protected $timezone;
/** /**
* @var callable|null * @var callable|null
@@ -150,7 +141,7 @@ class Logger implements LoggerInterface, ResettableInterface
* *
* @phpstan-param array<(callable(LogRecord): LogRecord)|ProcessorInterface> $processors * @phpstan-param array<(callable(LogRecord): LogRecord)|ProcessorInterface> $processors
*/ */
public function __construct(string $name, array $handlers = [], array $processors = [], ?DateTimeZone $timezone = null) public function __construct(string $name, array $handlers = [], array $processors = [], DateTimeZone|null $timezone = null)
{ {
$this->name = $name; $this->name = $name;
$this->setHandlers($handlers); $this->setHandlers($handlers);

View File

@@ -40,7 +40,7 @@ class GitProcessor implements ProcessorInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord
{ {

View File

@@ -18,8 +18,7 @@ use Monolog\LogRecord;
*/ */
class HostnameProcessor implements ProcessorInterface class HostnameProcessor implements ProcessorInterface
{ {
/** @var string */ private static string $host;
private static $host;
public function __construct() public function __construct()
{ {
@@ -27,7 +26,7 @@ class HostnameProcessor implements ProcessorInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord
{ {

View File

@@ -56,7 +56,7 @@ class IntrospectionProcessor implements ProcessorInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord
{ {

View File

@@ -22,7 +22,7 @@ use Monolog\LogRecord;
class MemoryPeakUsageProcessor extends MemoryProcessor class MemoryPeakUsageProcessor extends MemoryProcessor
{ {
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord
{ {

View File

@@ -21,12 +21,12 @@ abstract class MemoryProcessor implements ProcessorInterface
/** /**
* @var bool If true, get the real size of memory allocated from system. Else, only the memory used by emalloc() is reported. * @var bool If true, get the real size of memory allocated from system. Else, only the memory used by emalloc() is reported.
*/ */
protected $realUsage; protected bool $realUsage;
/** /**
* @var bool If true, then format memory size to human readable string (MB, KB, B depending on size) * @var bool If true, then format memory size to human readable string (MB, KB, B depending on size)
*/ */
protected $useFormatting; protected bool $useFormatting;
/** /**
* @param bool $realUsage Set this to true to get the real size of memory allocated from system. * @param bool $realUsage Set this to true to get the real size of memory allocated from system.

View File

@@ -22,7 +22,7 @@ use Monolog\LogRecord;
class MemoryUsageProcessor extends MemoryProcessor class MemoryUsageProcessor extends MemoryProcessor
{ {
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord
{ {

View File

@@ -39,7 +39,7 @@ class MercurialProcessor implements ProcessorInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord
{ {

View File

@@ -21,7 +21,7 @@ use Monolog\LogRecord;
class ProcessIdProcessor implements ProcessorInterface class ProcessIdProcessor implements ProcessorInterface
{ {
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord
{ {

View File

@@ -23,5 +23,5 @@ interface ProcessorInterface
/** /**
* @return LogRecord The processed record * @return LogRecord The processed record
*/ */
public function __invoke(LogRecord $record); public function __invoke(LogRecord $record): LogRecord;
} }

View File

@@ -25,11 +25,9 @@ class PsrLogMessageProcessor implements ProcessorInterface
{ {
public const SIMPLE_DATE = "Y-m-d\TH:i:s.uP"; public const SIMPLE_DATE = "Y-m-d\TH:i:s.uP";
/** @var string|null */ private ?string $dateFormat;
private $dateFormat;
/** @var bool */ private bool $removeUsedContextFields;
private $removeUsedContextFields;
/** /**
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
@@ -42,7 +40,7 @@ class PsrLogMessageProcessor implements ProcessorInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord
{ {

View File

@@ -21,7 +21,7 @@ use Monolog\LogRecord;
class TagProcessor implements ProcessorInterface class TagProcessor implements ProcessorInterface
{ {
/** @var string[] */ /** @var string[] */
private $tags; private array $tags;
/** /**
* @param string[] $tags * @param string[] $tags
@@ -52,7 +52,7 @@ class TagProcessor implements ProcessorInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord
{ {

View File

@@ -37,7 +37,7 @@ class UidProcessor implements ProcessorInterface, ResettableInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord
{ {
@@ -51,7 +51,7 @@ class UidProcessor implements ProcessorInterface, ResettableInterface
return $this->uid; return $this->uid;
} }
public function reset() public function reset(): void
{ {
$this->uid = $this->generateUid(strlen($this->uid)); $this->uid = $this->generateUid(strlen($this->uid));
} }

View File

@@ -32,7 +32,7 @@ class WebProcessor implements ProcessorInterface
* *
* @var array<string, string> * @var array<string, string>
*/ */
protected $extraFields = [ protected array $extraFields = [
'url' => 'REQUEST_URI', 'url' => 'REQUEST_URI',
'ip' => 'REMOTE_ADDR', 'ip' => 'REMOTE_ADDR',
'http_method' => 'REQUEST_METHOD', 'http_method' => 'REQUEST_METHOD',
@@ -76,7 +76,7 @@ class WebProcessor implements ProcessorInterface
} }
/** /**
* {@inheritDoc} * @inheritDoc
*/ */
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord
{ {

View File

@@ -42,7 +42,7 @@ class Registry
* *
* @var Logger[] * @var Logger[]
*/ */
private static $loggers = []; private static array $loggers = [];
/** /**
* Adds new logging channel to the registry * Adds new logging channel to the registry
@@ -51,9 +51,8 @@ class Registry
* @param string|null $name Name of the logging channel ($logger->getName() by default) * @param string|null $name Name of the logging channel ($logger->getName() by default)
* @param bool $overwrite Overwrite instance in the registry if the given name already exists? * @param bool $overwrite Overwrite instance in the registry if the given name already exists?
* @throws \InvalidArgumentException If $overwrite set to false and named Logger instance already exists * @throws \InvalidArgumentException If $overwrite set to false and named Logger instance already exists
* @return void
*/ */
public static function addLogger(Logger $logger, ?string $name = null, bool $overwrite = false) public static function addLogger(Logger $logger, ?string $name = null, bool $overwrite = false): void
{ {
$name = $name ?: $logger->getName(); $name = $name ?: $logger->getName();
@@ -110,7 +109,7 @@ class Registry
* @param string $name Name of the requested Logger instance * @param string $name Name of the requested Logger instance
* @throws \InvalidArgumentException If named Logger instance is not in the registry * @throws \InvalidArgumentException If named Logger instance is not in the registry
*/ */
public static function getInstance($name): Logger public static function getInstance(string $name): Logger
{ {
if (!isset(self::$loggers[$name])) { if (!isset(self::$loggers[$name])) {
throw new InvalidArgumentException(sprintf('Requested "%s" logger instance is not in the registry', $name)); throw new InvalidArgumentException(sprintf('Requested "%s" logger instance is not in the registry', $name));
@@ -127,7 +126,7 @@ class Registry
* @throws \InvalidArgumentException If named Logger instance is not in the registry * @throws \InvalidArgumentException If named Logger instance is not in the registry
* @return Logger Requested instance of Logger * @return Logger Requested instance of Logger
*/ */
public static function __callStatic($name, $arguments) public static function __callStatic(string $name, array $arguments): Logger
{ {
return self::getInstance($name); return self::getInstance($name);
} }

View File

@@ -27,8 +27,5 @@ namespace Monolog;
*/ */
interface ResettableInterface interface ResettableInterface
{ {
/** public function reset(): void;
* @return void
*/
public function reset();
} }

View File

@@ -22,15 +22,14 @@ use ReflectionExtension;
*/ */
class SignalHandler class SignalHandler
{ {
/** @var LoggerInterface */ private LoggerInterface $logger;
private $logger;
/** @var array<int, callable|string|int> SIG_DFL, SIG_IGN or previous callable */ /** @var array<int, callable|string|int> SIG_DFL, SIG_IGN or previous callable */
private $previousSignalHandler = []; private array $previousSignalHandler = [];
/** @var array<int, \Psr\Log\LogLevel::*> */ /** @var array<int, \Psr\Log\LogLevel::*> */
private $signalLevelMap = []; private array $signalLevelMap = [];
/** @var array<int, bool> */ /** @var array<int, bool> */
private $signalRestartSyscalls = []; private array $signalRestartSyscalls = [];
public function __construct(LoggerInterface $logger) public function __construct(LoggerInterface $logger)
{ {

View File

@@ -125,7 +125,6 @@ class ErrorHandlerTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('E_DEPRECATED', $method->invokeArgs(null, [E_DEPRECATED])); $this->assertEquals('E_DEPRECATED', $method->invokeArgs(null, [E_DEPRECATED]));
$this->assertEquals('E_USER_DEPRECATED', $method->invokeArgs(null, [E_USER_DEPRECATED])); $this->assertEquals('E_USER_DEPRECATED', $method->invokeArgs(null, [E_USER_DEPRECATED]));
$this->assertEquals('Unknown PHP error', $method->invokeArgs(null, ['RANDOM_TEXT']));
$this->assertEquals('Unknown PHP error', $method->invokeArgs(null, [E_ALL])); $this->assertEquals('Unknown PHP error', $method->invokeArgs(null, [E_ALL]));
} }
} }

View File

@@ -191,12 +191,9 @@ class JsonFormatterTest extends TestCase
} }
/** /**
* @param string $expected
* @param string $actual
*
* @internal param string $exception * @internal param string $exception
*/ */
private function assertContextContainsFormattedException($expected, $actual) private function assertContextContainsFormattedException(string $expected, string $actual)
{ {
$this->assertEquals( $this->assertEquals(
'{"message":"foobar","context":{"exception":'.$expected.'},"level":500,"level_name":"CRITICAL","channel":"core","datetime":"2022-02-22T00:00:00+00:00","extra":{}}'."\n", '{"message":"foobar","context":{"exception":'.$expected.'},"level":500,"level_name":"CRITICAL","channel":"core","datetime":"2022-02-22T00:00:00+00:00","extra":{}}'."\n",
@@ -204,10 +201,7 @@ class JsonFormatterTest extends TestCase
); );
} }
/** private function formatRecordWithExceptionInContext(JsonFormatter $formatter, \Throwable $exception): string
* @return string
*/
private function formatRecordWithExceptionInContext(JsonFormatter $formatter, \Throwable $exception)
{ {
$message = $formatter->format($this->getRecord( $message = $formatter->format($this->getRecord(
Level::Critical, Level::Critical,
@@ -222,10 +216,8 @@ class JsonFormatterTest extends TestCase
/** /**
* @param \Exception|\Throwable $exception * @param \Exception|\Throwable $exception
*
* @return string
*/ */
private function formatExceptionFilePathWithLine($exception) private function formatExceptionFilePathWithLine($exception): string
{ {
$options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
$path = substr(json_encode($exception->getFile(), $options), 1, -1); $path = substr(json_encode($exception->getFile(), $options), 1, -1);
@@ -235,12 +227,8 @@ class JsonFormatterTest extends TestCase
/** /**
* @param \Exception|\Throwable $exception * @param \Exception|\Throwable $exception
*
* @param null|string $previous
*
* @return string
*/ */
private function formatException($exception, $previous = null) private function formatException($exception, ?string $previous = null): string
{ {
$formattedException = $formattedException =
'{"class":"' . get_class($exception) . '{"class":"' . get_class($exception) .

View File

@@ -371,10 +371,7 @@ class NormalizerFormatterTest extends TestCase
); );
} }
/** private function formatRecordWithExceptionInContext(NormalizerFormatter $formatter, \Throwable $exception): array
* @return string
*/
private function formatRecordWithExceptionInContext(NormalizerFormatter $formatter, \Throwable $exception)
{ {
$message = $formatter->format($this->getRecord( $message = $formatter->format($this->getRecord(
Level::Critical, Level::Critical,

Some files were not shown because too many files have changed in this diff Show More