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

Merge pull request #1243 from gmponos/docblock_fixes

Docblock fixes
This commit is contained in:
Jordi Boggiano
2018-12-11 07:45:10 +01:00
committed by GitHub
23 changed files with 49 additions and 37 deletions

View File

@@ -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) public function __construct(?string $dateFormat = null)
{ {
@@ -68,7 +68,7 @@ class HtmlFormatter extends NormalizerFormatter
* @param int $level Error level * @param int $level Error level
* @return string * @return string
*/ */
protected function addTitle(string $title, int $level) protected function addTitle(string $title, int $level): string
{ {
$title = htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8'); $title = htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8');

View File

@@ -31,8 +31,8 @@ class LineFormatter extends NormalizerFormatter
protected $includeStacktraces; protected $includeStacktraces;
/** /**
* @param ?string $format The format of the message * @param string|null $format The format of the message
* @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
* @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries * @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries
* @param bool $ignoreEmptyContextAndExtra * @param bool $ignoreEmptyContextAndExtra
*/ */

View File

@@ -42,10 +42,10 @@ class LogstashFormatter extends NormalizerFormatter
protected $contextKey; protected $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
* @param ?string $systemName the system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine * @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 $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 $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') public function __construct(string $applicationName, ?string $systemName = null, string $extraKey = 'extra', string $contextKey = 'context')
{ {

View File

@@ -31,7 +31,7 @@ class NormalizerFormatter implements FormatterInterface
private $jsonEncodeOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION; 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) public function __construct(?string $dateFormat = null)
{ {

View File

@@ -44,7 +44,7 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
{ {
parent::__construct($level, $bubble); parent::__construct($level, $bubble);
$this->handler = $handler; $this->handler = $handler;
$this->bufferLimit = (int) $bufferLimit; $this->bufferLimit = $bufferLimit;
$this->flushOnOverflow = $flushOnOverflow; $this->flushOnOverflow = $flushOnOverflow;
} }

View File

@@ -39,7 +39,7 @@ class ProcessHandler extends AbstractProcessingHandler
private $command; private $command;
/** /**
* @var ?string * @var string|null
*/ */
private $cwd; private $cwd;
@@ -62,7 +62,7 @@ class ProcessHandler extends AbstractProcessingHandler
* especially if you do not use the $cwd parameter. * especially if you do not use the $cwd parameter.
* @param string|int $level The minimum logging level at which this handler will be triggered. * @param 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 $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 * @throws \InvalidArgumentException
*/ */
public function __construct(string $command, $level = Logger::DEBUG, bool $bubble = true, ?string $cwd = null) public function __construct(string $command, $level = Logger::DEBUG, bool $bubble = true, ?string $cwd = null)

View File

@@ -11,6 +11,8 @@
namespace Monolog\Handler; namespace Monolog\Handler;
use Monolog\Processor\ProcessorInterface;
/** /**
* Interface to describe loggers that have processors * Interface to describe loggers that have processors
* *

View File

@@ -34,7 +34,7 @@ class PsrHandler extends AbstractHandler implements FormattableHandlerInterface
protected $logger; protected $logger;
/** /**
* @var FormatterInterface * @var FormatterInterface|null
*/ */
protected $formatter; protected $formatter;

View File

@@ -67,7 +67,7 @@ class PushoverHandler extends SocketHandler
/** /**
* @param string $token Pushover api token * @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|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 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 $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 * @param bool $useSSL Whether to connect via SSL. Required when pushing messages to users that are not

View File

@@ -55,7 +55,7 @@ class RavenHandler extends AbstractProcessingHandler
protected $ravenClient; 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; protected $batchFormatter;

View File

@@ -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) public function __construct(string $filename, int $maxFiles = 0, $level = Logger::DEBUG, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false)
{ {
$this->filename = $filename; $this->filename = $filename;
$this->maxFiles = (int) $maxFiles; $this->maxFiles = $maxFiles;
$this->nextRotation = new \DateTimeImmutable('tomorrow'); $this->nextRotation = new \DateTimeImmutable('tomorrow');
$this->filenameFormat = '{filename}-{date}'; $this->filenameFormat = '{filename}-{date}';
$this->dateFormat = static::FILE_PER_DAY; $this->dateFormat = static::FILE_PER_DAY;

View File

@@ -35,13 +35,13 @@ class SlackRecord
/** /**
* Slack channel (encoded ID or name) * Slack channel (encoded ID or name)
* @var ?string * @var string|null
*/ */
private $channel; private $channel;
/** /**
* Name of a bot * Name of a bot
* @var ?string * @var string|null
*/ */
private $username; private $username;

View File

@@ -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 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 HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc.
* @param callable[] $processors Optional array of processors * @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) public function __construct(string $name, array $handlers = [], array $processors = [], ?DateTimeZone $timezone = null)
{ {

View File

@@ -24,6 +24,9 @@ class GitProcessor implements ProcessorInterface
private $level; private $level;
private static $cache; private static $cache;
/**
* @param string|int $level The minimum logging level at which this Processor will be triggered
*/
public function __construct($level = Logger::DEBUG) public function __construct($level = Logger::DEBUG)
{ {
$this->level = Logger::toMonologLevel($level); $this->level = Logger::toMonologLevel($level);

View File

@@ -37,6 +37,9 @@ class IntrospectionProcessor implements ProcessorInterface
'call_user_func_array', '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) public function __construct($level = Logger::DEBUG, array $skipClassesPartials = [], int $skipStackFramesCount = 0)
{ {
$this->level = Logger::toMonologLevel($level); $this->level = Logger::toMonologLevel($level);

View File

@@ -23,6 +23,9 @@ class MercurialProcessor implements ProcessorInterface
private $level; private $level;
private static $cache; private static $cache;
/**
* @param string|int $level The minimum logging level at which this Processor will be triggered
*/
public function __construct($level = Logger::DEBUG) public function __construct($level = Logger::DEBUG)
{ {
$this->level = Logger::toMonologLevel($level); $this->level = Logger::toMonologLevel($level);

View File

@@ -24,14 +24,14 @@ 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 */ /** @var string|null */
private $dateFormat; private $dateFormat;
/** @var bool */ /** @var bool */
private $removeUsedContextFields; private $removeUsedContextFields;
/** /**
* @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
* @param bool $removeUsedContextFields If set to true the fields interpolated into message gets unset * @param bool $removeUsedContextFields If set to true the fields interpolated into message gets unset
*/ */
public function __construct(?string $dateFormat = null, bool $removeUsedContextFields = false) public function __construct(?string $dateFormat = null, bool $removeUsedContextFields = false)

View File

@@ -24,7 +24,7 @@ class UidProcessor implements ProcessorInterface, ResettableInterface
public function __construct(int $length = 7) 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'); 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 $record;
} }
/**
* @return string
*/
public function getUid(): string public function getUid(): string
{ {
return $this->uid; return $this->uid;
@@ -51,7 +48,7 @@ class UidProcessor implements ProcessorInterface, ResettableInterface
$this->uid = $this->generateUid(strlen($this->uid)); $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); return substr(bin2hex(random_bytes((int) ceil($length / 2))), 0, $length);
} }

View File

@@ -39,7 +39,7 @@ class WebProcessor implements ProcessorInterface
]; ];
/** /**
* @param array|\ArrayAccess $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data * @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 * @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) public function __construct($serverData = null, array $extraFields = null)

View File

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

View File

@@ -19,7 +19,7 @@ use PhpConsole\Connector;
use PhpConsole\Dispatcher\Debug as DebugDispatcher; use PhpConsole\Dispatcher\Debug as DebugDispatcher;
use PhpConsole\Dispatcher\Errors as ErrorDispatcher; use PhpConsole\Dispatcher\Errors as ErrorDispatcher;
use PhpConsole\Handler as VendorPhpConsoleHandler; use PhpConsole\Handler as VendorPhpConsoleHandler;
use PHPUnit_Framework_MockObject_MockObject; use PHPUnit\Framework\MockObject\MockObject;
/** /**
* @covers Monolog\Handler\PHPConsoleHandler * @covers Monolog\Handler\PHPConsoleHandler
@@ -27,11 +27,11 @@ use PHPUnit_Framework_MockObject_MockObject;
*/ */
class PHPConsoleHandlerTest extends TestCase class PHPConsoleHandlerTest extends TestCase
{ {
/** @var Connector|PHPUnit_Framework_MockObject_MockObject */ /** @var Connector|MockObject */
protected $connector; protected $connector;
/** @var DebugDispatcher|PHPUnit_Framework_MockObject_MockObject */ /** @var DebugDispatcher|MockObject */
protected $debugDispatcher; protected $debugDispatcher;
/** @var ErrorDispatcher|PHPUnit_Framework_MockObject_MockObject */ /** @var ErrorDispatcher|MockObject */
protected $errorDispatcher; protected $errorDispatcher;
protected function setUp() protected function setUp()

View File

@@ -14,7 +14,7 @@ namespace Monolog\Handler;
use Exception; use Exception;
use Monolog\Test\TestCase; use Monolog\Test\TestCase;
use Monolog\Logger; use Monolog\Logger;
use PHPUnit_Framework_MockObject_MockObject as MockObject; use PHPUnit\Framework\MockObject\MockObject;
use Rollbar\RollbarLogger; use Rollbar\RollbarLogger;
/** /**

View File

@@ -13,10 +13,11 @@ namespace Monolog\Handler;
use Monolog\Logger; use Monolog\Logger;
use Monolog\Test\TestCase; use Monolog\Test\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
class SwiftMailerHandlerTest extends TestCase class SwiftMailerHandlerTest extends TestCase
{ {
/** @var \Swift_Mailer|\PHPUnit_Framework_MockObject_MockObject */ /** @var \Swift_Mailer|MockObject */
private $mailer; private $mailer;
public function setUp() public function setUp()