Jelajahi Sumber

Merge pull request #1243 from gmponos/docblock_fixes

Docblock fixes
Jordi Boggiano 7 tahun lalu
induk
melakukan
941be72a5d

+ 2 - 2
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');
 

+ 4 - 4
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)
     {

+ 4 - 4
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')
     {

+ 1 - 1
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)
     {

+ 1 - 1
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;
     }
 

+ 2 - 2
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)

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

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

+ 1 - 1
src/Monolog/Handler/PsrHandler.php

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

+ 1 - 1
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

+ 1 - 1
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;
 

+ 1 - 1
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;

+ 2 - 2
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;
 

+ 1 - 1
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)
     {

+ 3 - 0
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);

+ 3 - 0
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);

+ 3 - 0
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);

+ 3 - 3
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)
     {

+ 2 - 5
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);
     }

+ 2 - 2
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)
     {

+ 3 - 0
src/Monolog/ResettableInterface.php

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

+ 4 - 4
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()

+ 1 - 1
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;
 
 /**

+ 2 - 1
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()