diff --git a/src/Monolog/Formatter/HtmlFormatter.php b/src/Monolog/Formatter/HtmlFormatter.php index 0f8db9a7..3c4e8479 100644 --- a/src/Monolog/Formatter/HtmlFormatter.php +++ b/src/Monolog/Formatter/HtmlFormatter.php @@ -37,7 +37,7 @@ class HtmlFormatter extends NormalizerFormatter ]; /** - * @param ?string $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 */ public function __construct(?string $dateFormat = null) { @@ -68,7 +68,7 @@ class HtmlFormatter extends NormalizerFormatter * @param int $level Error level * @return string */ - protected function addTitle(string $title, int $level) + protected function addTitle(string $title, int $level): string { $title = htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8'); diff --git a/src/Monolog/Formatter/LineFormatter.php b/src/Monolog/Formatter/LineFormatter.php index 3b4824cd..64f57bec 100644 --- a/src/Monolog/Formatter/LineFormatter.php +++ b/src/Monolog/Formatter/LineFormatter.php @@ -31,10 +31,10 @@ class LineFormatter extends NormalizerFormatter protected $includeStacktraces; /** - * @param ?string $format The format of the message - * @param ?string $dateFormat The format of the timestamp: one supported by DateTime::format - * @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries - * @param bool $ignoreEmptyContextAndExtra + * @param string|null $format The format of the message + * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format + * @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries + * @param bool $ignoreEmptyContextAndExtra */ public function __construct(?string $format = null, ?string $dateFormat = null, bool $allowInlineLineBreaks = false, bool $ignoreEmptyContextAndExtra = false) { diff --git a/src/Monolog/Formatter/LogstashFormatter.php b/src/Monolog/Formatter/LogstashFormatter.php index 6404acf0..563d97db 100644 --- a/src/Monolog/Formatter/LogstashFormatter.php +++ b/src/Monolog/Formatter/LogstashFormatter.php @@ -42,10 +42,10 @@ class LogstashFormatter extends NormalizerFormatter protected $contextKey; /** - * @param string $applicationName the application that sends the data, used as the "type" field of logstash - * @param ?string $systemName the system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine - * @param string $extraKey the key for extra keys inside logstash "fields", defaults to extra - * @param string $contextKey the key for context keys inside logstash "fields", defaults to context + * @param string $applicationName The application that sends the data, used as the "type" field of logstash + * @param string|null $systemName The system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine + * @param string $extraKey The key for extra keys inside logstash "fields", defaults to extra + * @param string $contextKey The key for context keys inside logstash "fields", defaults to context */ public function __construct(string $applicationName, ?string $systemName = null, string $extraKey = 'extra', string $contextKey = 'context') { diff --git a/src/Monolog/Formatter/NormalizerFormatter.php b/src/Monolog/Formatter/NormalizerFormatter.php index ea5a2a65..4bd13b19 100644 --- a/src/Monolog/Formatter/NormalizerFormatter.php +++ b/src/Monolog/Formatter/NormalizerFormatter.php @@ -31,7 +31,7 @@ class NormalizerFormatter implements FormatterInterface private $jsonEncodeOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION; /** - * @param ?string $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 */ public function __construct(?string $dateFormat = null) { diff --git a/src/Monolog/Handler/BufferHandler.php b/src/Monolog/Handler/BufferHandler.php index a73a9778..d9505b79 100644 --- a/src/Monolog/Handler/BufferHandler.php +++ b/src/Monolog/Handler/BufferHandler.php @@ -44,7 +44,7 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa { parent::__construct($level, $bubble); $this->handler = $handler; - $this->bufferLimit = (int) $bufferLimit; + $this->bufferLimit = $bufferLimit; $this->flushOnOverflow = $flushOnOverflow; } diff --git a/src/Monolog/Handler/ProcessHandler.php b/src/Monolog/Handler/ProcessHandler.php index dd13ee4e..36e30b87 100644 --- a/src/Monolog/Handler/ProcessHandler.php +++ b/src/Monolog/Handler/ProcessHandler.php @@ -39,7 +39,7 @@ class ProcessHandler extends AbstractProcessingHandler private $command; /** - * @var ?string + * @var string|null */ private $cwd; @@ -62,7 +62,7 @@ class ProcessHandler extends AbstractProcessingHandler * especially if you do not use the $cwd parameter. * @param string|int $level The minimum logging level at which this handler will be triggered. * @param bool $bubble Whether the messages that are handled can bubble up the stack or not. - * @param ?string $cwd "Current working directory" (CWD) for the process to be executed in. + * @param string|null $cwd "Current working directory" (CWD) for the process to be executed in. * @throws \InvalidArgumentException */ public function __construct(string $command, $level = Logger::DEBUG, bool $bubble = true, ?string $cwd = null) diff --git a/src/Monolog/Handler/ProcessableHandlerInterface.php b/src/Monolog/Handler/ProcessableHandlerInterface.php index 27077c62..2c9557b4 100644 --- a/src/Monolog/Handler/ProcessableHandlerInterface.php +++ b/src/Monolog/Handler/ProcessableHandlerInterface.php @@ -11,6 +11,8 @@ namespace Monolog\Handler; +use Monolog\Processor\ProcessorInterface; + /** * Interface to describe loggers that have processors * diff --git a/src/Monolog/Handler/PsrHandler.php b/src/Monolog/Handler/PsrHandler.php index e0c67dcd..cba96a55 100644 --- a/src/Monolog/Handler/PsrHandler.php +++ b/src/Monolog/Handler/PsrHandler.php @@ -34,7 +34,7 @@ class PsrHandler extends AbstractHandler implements FormattableHandlerInterface protected $logger; /** - * @var FormatterInterface + * @var FormatterInterface|null */ protected $formatter; diff --git a/src/Monolog/Handler/PushoverHandler.php b/src/Monolog/Handler/PushoverHandler.php index 3d07e41f..2689de1c 100644 --- a/src/Monolog/Handler/PushoverHandler.php +++ b/src/Monolog/Handler/PushoverHandler.php @@ -67,7 +67,7 @@ class PushoverHandler extends SocketHandler /** * @param string $token Pushover api token * @param string|array $users Pushover user id or array of ids the message will be sent to - * @param string $title Title sent to the Pushover API + * @param string|null $title Title sent to the Pushover API * @param string|int $level The minimum logging level at which this handler will be triggered * @param bool $bubble Whether the messages that are handled can bubble up the stack or not * @param bool $useSSL Whether to connect via SSL. Required when pushing messages to users that are not diff --git a/src/Monolog/Handler/RavenHandler.php b/src/Monolog/Handler/RavenHandler.php index 6836c488..6c3c32bf 100644 --- a/src/Monolog/Handler/RavenHandler.php +++ b/src/Monolog/Handler/RavenHandler.php @@ -55,7 +55,7 @@ class RavenHandler extends AbstractProcessingHandler protected $ravenClient; /** - * @var LineFormatter The formatter to use for the logs generated via handleBatch() + * @var FormatterInterface The formatter to use for the logs generated via handleBatch() */ protected $batchFormatter; diff --git a/src/Monolog/Handler/RotatingFileHandler.php b/src/Monolog/Handler/RotatingFileHandler.php index 387c89ad..3e2810ba 100644 --- a/src/Monolog/Handler/RotatingFileHandler.php +++ b/src/Monolog/Handler/RotatingFileHandler.php @@ -47,7 +47,7 @@ class RotatingFileHandler extends StreamHandler public function __construct(string $filename, int $maxFiles = 0, $level = Logger::DEBUG, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false) { $this->filename = $filename; - $this->maxFiles = (int) $maxFiles; + $this->maxFiles = $maxFiles; $this->nextRotation = new \DateTimeImmutable('tomorrow'); $this->filenameFormat = '{filename}-{date}'; $this->dateFormat = static::FILE_PER_DAY; diff --git a/src/Monolog/Handler/Slack/SlackRecord.php b/src/Monolog/Handler/Slack/SlackRecord.php index f18fbe80..e2f66492 100644 --- a/src/Monolog/Handler/Slack/SlackRecord.php +++ b/src/Monolog/Handler/Slack/SlackRecord.php @@ -35,13 +35,13 @@ class SlackRecord /** * Slack channel (encoded ID or name) - * @var ?string + * @var string|null */ private $channel; /** * Name of a bot - * @var ?string + * @var string|null */ private $username; diff --git a/src/Monolog/Logger.php b/src/Monolog/Logger.php index d6eeb9ea..6d48c135 100644 --- a/src/Monolog/Logger.php +++ b/src/Monolog/Logger.php @@ -143,7 +143,7 @@ class Logger implements LoggerInterface, ResettableInterface * @param string $name The logging channel, a simple descriptive name that is attached to all log records * @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc. * @param callable[] $processors Optional array of processors - * @param ?DateTimeZone $timezone Optional timezone, if not provided date_default_timezone_get() will be used + * @param DateTimeZone|null $timezone Optional timezone, if not provided date_default_timezone_get() will be used */ public function __construct(string $name, array $handlers = [], array $processors = [], ?DateTimeZone $timezone = null) { diff --git a/src/Monolog/Processor/GitProcessor.php b/src/Monolog/Processor/GitProcessor.php index b72944c7..1367ee6f 100644 --- a/src/Monolog/Processor/GitProcessor.php +++ b/src/Monolog/Processor/GitProcessor.php @@ -24,6 +24,9 @@ class GitProcessor implements ProcessorInterface private $level; private static $cache; + /** + * @param string|int $level The minimum logging level at which this Processor will be triggered + */ public function __construct($level = Logger::DEBUG) { $this->level = Logger::toMonologLevel($level); diff --git a/src/Monolog/Processor/IntrospectionProcessor.php b/src/Monolog/Processor/IntrospectionProcessor.php index 691d573c..c0cc014e 100644 --- a/src/Monolog/Processor/IntrospectionProcessor.php +++ b/src/Monolog/Processor/IntrospectionProcessor.php @@ -37,6 +37,9 @@ class IntrospectionProcessor implements ProcessorInterface 'call_user_func_array', ]; + /** + * @param string|int $level The minimum logging level at which this Processor will be triggered + */ public function __construct($level = Logger::DEBUG, array $skipClassesPartials = [], int $skipStackFramesCount = 0) { $this->level = Logger::toMonologLevel($level); diff --git a/src/Monolog/Processor/MercurialProcessor.php b/src/Monolog/Processor/MercurialProcessor.php index b7fcd784..d50f7138 100644 --- a/src/Monolog/Processor/MercurialProcessor.php +++ b/src/Monolog/Processor/MercurialProcessor.php @@ -23,6 +23,9 @@ class MercurialProcessor implements ProcessorInterface private $level; private static $cache; + /** + * @param string|int $level The minimum logging level at which this Processor will be triggered + */ public function __construct($level = Logger::DEBUG) { $this->level = Logger::toMonologLevel($level); diff --git a/src/Monolog/Processor/PsrLogMessageProcessor.php b/src/Monolog/Processor/PsrLogMessageProcessor.php index 65eccc6f..909fc4fd 100644 --- a/src/Monolog/Processor/PsrLogMessageProcessor.php +++ b/src/Monolog/Processor/PsrLogMessageProcessor.php @@ -24,15 +24,15 @@ class PsrLogMessageProcessor implements ProcessorInterface { public const SIMPLE_DATE = "Y-m-d\TH:i:s.uP"; - /** @var ?string */ + /** @var string|null */ private $dateFormat; /** @var bool */ private $removeUsedContextFields; /** - * @param ?string $dateFormat The format of the timestamp: one supported by DateTime::format - * @param bool $removeUsedContextFields If set to true the fields interpolated into message gets unset + * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format + * @param bool $removeUsedContextFields If set to true the fields interpolated into message gets unset */ public function __construct(?string $dateFormat = null, bool $removeUsedContextFields = false) { diff --git a/src/Monolog/Processor/UidProcessor.php b/src/Monolog/Processor/UidProcessor.php index 1089e690..0c97ab6c 100644 --- a/src/Monolog/Processor/UidProcessor.php +++ b/src/Monolog/Processor/UidProcessor.php @@ -24,7 +24,7 @@ class UidProcessor implements ProcessorInterface, ResettableInterface public function __construct(int $length = 7) { - if (!is_int($length) || $length > 32 || $length < 1) { + if ($length > 32 || $length < 1) { throw new \InvalidArgumentException('The uid length must be an integer between 1 and 32'); } @@ -38,9 +38,6 @@ class UidProcessor implements ProcessorInterface, ResettableInterface return $record; } - /** - * @return string - */ public function getUid(): string { return $this->uid; @@ -51,7 +48,7 @@ class UidProcessor implements ProcessorInterface, ResettableInterface $this->uid = $this->generateUid(strlen($this->uid)); } - private function generateUid($length) + private function generateUid(int $length): string { return substr(bin2hex(random_bytes((int) ceil($length / 2))), 0, $length); } diff --git a/src/Monolog/Processor/WebProcessor.php b/src/Monolog/Processor/WebProcessor.php index 6b0a8d42..7b95b0e1 100644 --- a/src/Monolog/Processor/WebProcessor.php +++ b/src/Monolog/Processor/WebProcessor.php @@ -39,8 +39,8 @@ class WebProcessor implements ProcessorInterface ]; /** - * @param array|\ArrayAccess $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data - * @param array|null $extraFields Field names and the related key inside $serverData to be added. If not provided it defaults to: url, ip, http_method, server, referrer + * @param array|\ArrayAccess|null $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data + * @param array|null $extraFields Field names and the related key inside $serverData to be added. If not provided it defaults to: url, ip, http_method, server, referrer */ public function __construct($serverData = null, array $extraFields = null) { diff --git a/src/Monolog/ResettableInterface.php b/src/Monolog/ResettableInterface.php index 081081f7..2c5fd785 100644 --- a/src/Monolog/ResettableInterface.php +++ b/src/Monolog/ResettableInterface.php @@ -27,5 +27,8 @@ namespace Monolog; */ interface ResettableInterface { + /** + * @return void + */ public function reset(); } diff --git a/tests/Monolog/Handler/PHPConsoleHandlerTest.php b/tests/Monolog/Handler/PHPConsoleHandlerTest.php index 0836b995..9c479da6 100644 --- a/tests/Monolog/Handler/PHPConsoleHandlerTest.php +++ b/tests/Monolog/Handler/PHPConsoleHandlerTest.php @@ -19,7 +19,7 @@ use PhpConsole\Connector; use PhpConsole\Dispatcher\Debug as DebugDispatcher; use PhpConsole\Dispatcher\Errors as ErrorDispatcher; use PhpConsole\Handler as VendorPhpConsoleHandler; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; /** * @covers Monolog\Handler\PHPConsoleHandler @@ -27,11 +27,11 @@ use PHPUnit_Framework_MockObject_MockObject; */ class PHPConsoleHandlerTest extends TestCase { - /** @var Connector|PHPUnit_Framework_MockObject_MockObject */ + /** @var Connector|MockObject */ protected $connector; - /** @var DebugDispatcher|PHPUnit_Framework_MockObject_MockObject */ + /** @var DebugDispatcher|MockObject */ protected $debugDispatcher; - /** @var ErrorDispatcher|PHPUnit_Framework_MockObject_MockObject */ + /** @var ErrorDispatcher|MockObject */ protected $errorDispatcher; protected function setUp() diff --git a/tests/Monolog/Handler/RollbarHandlerTest.php b/tests/Monolog/Handler/RollbarHandlerTest.php index 67a0eb68..5d8c1fc2 100644 --- a/tests/Monolog/Handler/RollbarHandlerTest.php +++ b/tests/Monolog/Handler/RollbarHandlerTest.php @@ -14,7 +14,7 @@ namespace Monolog\Handler; use Exception; use Monolog\Test\TestCase; use Monolog\Logger; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; use Rollbar\RollbarLogger; /** diff --git a/tests/Monolog/Handler/SwiftMailerHandlerTest.php b/tests/Monolog/Handler/SwiftMailerHandlerTest.php index 3c77127b..d8ff39bc 100644 --- a/tests/Monolog/Handler/SwiftMailerHandlerTest.php +++ b/tests/Monolog/Handler/SwiftMailerHandlerTest.php @@ -13,10 +13,11 @@ namespace Monolog\Handler; use Monolog\Logger; use Monolog\Test\TestCase; +use PHPUnit\Framework\MockObject\MockObject; class SwiftMailerHandlerTest extends TestCase { - /** @var \Swift_Mailer|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Swift_Mailer|MockObject */ private $mailer; public function setUp()