Bläddra i källkod

Code cleanups

Jordi Boggiano 3 år sedan
förälder
incheckning
5eb9b8ed93
100 ändrade filer med 375 tillägg och 506 borttagningar
  1. 6 6
      doc/01-usage.md
  2. 5 5
      doc/04-extending.md
  3. 10 10
      src/Monolog/Formatter/ChromePHPFormatter.php
  4. 6 6
      src/Monolog/Formatter/FlowdockFormatter.php
  5. 8 8
      src/Monolog/Formatter/FluentdFormatter.php
  6. 11 11
      src/Monolog/Formatter/GelfMessageFormatter.php
  7. 8 8
      src/Monolog/Formatter/HtmlFormatter.php
  8. 9 11
      src/Monolog/Formatter/JsonFormatter.php
  9. 17 17
      src/Monolog/Formatter/LogstashFormatter.php
  10. 1 1
      src/Monolog/Formatter/MongoDBFormatter.php
  11. 16 16
      src/Monolog/Formatter/WildfireFormatter.php
  12. 1 1
      src/Monolog/Handler/AbstractHandler.php
  13. 2 6
      src/Monolog/Handler/AbstractProcessingHandler.php
  14. 2 8
      src/Monolog/Handler/AmqpHandler.php
  15. 16 18
      src/Monolog/Handler/BrowserConsoleHandler.php
  16. 13 16
      src/Monolog/Handler/BufferHandler.php
  17. 3 5
      src/Monolog/Handler/ChromePHPHandler.php
  18. 1 1
      src/Monolog/Handler/CouchDBHandler.php
  19. 8 8
      src/Monolog/Handler/CubeHandler.php
  20. 1 1
      src/Monolog/Handler/Curl/Util.php
  21. 5 13
      src/Monolog/Handler/DeduplicationHandler.php
  22. 1 1
      src/Monolog/Handler/DoctrineCouchDBHandler.php
  23. 1 1
      src/Monolog/Handler/DynamoDbHandler.php
  24. 1 1
      src/Monolog/Handler/ElasticaHandler.php
  25. 2 2
      src/Monolog/Handler/ElasticsearchHandler.php
  26. 2 2
      src/Monolog/Handler/ErrorLogHandler.php
  27. 0 4
      src/Monolog/Handler/FallbackGroupHandler.php
  28. 3 8
      src/Monolog/Handler/FilterHandler.php
  29. 0 4
      src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php
  30. 3 8
      src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php
  31. 1 1
      src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php
  32. 4 9
      src/Monolog/Handler/FingersCrossedHandler.php
  33. 1 5
      src/Monolog/Handler/FirePHPHandler.php
  34. 1 5
      src/Monolog/Handler/FleepHookHandler.php
  35. 1 5
      src/Monolog/Handler/FlowdockHandler.php
  36. 1 1
      src/Monolog/Handler/GelfHandler.php
  37. 0 4
      src/Monolog/Handler/GroupHandler.php
  38. 2 2
      src/Monolog/Handler/IFTTTHandler.php
  39. 1 1
      src/Monolog/Handler/InsightOpsHandler.php
  40. 1 1
      src/Monolog/Handler/LogEntriesHandler.php
  41. 5 5
      src/Monolog/Handler/LogglyHandler.php
  42. 1 1
      src/Monolog/Handler/LogmaticHandler.php
  43. 4 6
      src/Monolog/Handler/MailHandler.php
  44. 1 1
      src/Monolog/Handler/MandrillHandler.php
  45. 7 8
      src/Monolog/Handler/MongoDBHandler.php
  46. 12 12
      src/Monolog/Handler/NewRelicHandler.php
  47. 2 2
      src/Monolog/Handler/NullHandler.php
  48. 2 2
      src/Monolog/Handler/OverflowHandler.php
  49. 5 16
      src/Monolog/Handler/PHPConsoleHandler.php
  50. 1 1
      src/Monolog/Handler/ProcessHandler.php
  51. 3 4
      src/Monolog/Handler/ProcessableHandlerInterface.php
  52. 1 1
      src/Monolog/Handler/ProcessableHandlerTrait.php
  53. 2 2
      src/Monolog/Handler/PsrHandler.php
  54. 6 10
      src/Monolog/Handler/PushoverHandler.php
  55. 5 9
      src/Monolog/Handler/RedisHandler.php
  56. 3 3
      src/Monolog/Handler/RedisPubSubHandler.php
  57. 7 7
      src/Monolog/Handler/RollbarHandler.php
  58. 1 1
      src/Monolog/Handler/RotatingFileHandler.php
  59. 2 7
      src/Monolog/Handler/SamplingHandler.php
  60. 15 22
      src/Monolog/Handler/Slack/SlackRecord.php
  61. 0 5
      src/Monolog/Handler/SlackHandler.php
  62. 1 7
      src/Monolog/Handler/SocketHandler.php
  63. 2 2
      src/Monolog/Handler/SqsHandler.php
  64. 1 6
      src/Monolog/Handler/StreamHandler.php
  65. 1 1
      src/Monolog/Handler/SyslogHandler.php
  66. 2 2
      src/Monolog/Handler/SyslogUdpHandler.php
  67. 1 5
      src/Monolog/Handler/TelegramBotHandler.php
  68. 11 15
      src/Monolog/Handler/TestHandler.php
  69. 3 6
      src/Monolog/Handler/WhatFailureGroupHandler.php
  70. 5 9
      src/Monolog/Handler/ZendMonitorHandler.php
  71. 2 2
      src/Monolog/Processor/GitProcessor.php
  72. 1 1
      src/Monolog/Processor/HostnameProcessor.php
  73. 13 13
      src/Monolog/Processor/IntrospectionProcessor.php
  74. 1 1
      src/Monolog/Processor/MemoryPeakUsageProcessor.php
  75. 1 1
      src/Monolog/Processor/MemoryUsageProcessor.php
  76. 2 2
      src/Monolog/Processor/MercurialProcessor.php
  77. 1 1
      src/Monolog/Processor/ProcessIdProcessor.php
  78. 4 4
      src/Monolog/Processor/PsrLogMessageProcessor.php
  79. 1 1
      src/Monolog/Processor/UidProcessor.php
  80. 1 1
      src/Monolog/Processor/WebProcessor.php
  81. 2 1
      src/Monolog/Test/TestCase.php
  82. 4 4
      tests/Monolog/Formatter/JsonFormatterTest.php
  83. 1 1
      tests/Monolog/Formatter/LogglyFormatterTest.php
  84. 1 1
      tests/Monolog/Handler/BufferHandlerTest.php
  85. 2 2
      tests/Monolog/Handler/DeduplicationHandlerTest.php
  86. 1 1
      tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php
  87. 3 3
      tests/Monolog/Handler/FallbackGroupHandlerTest.php
  88. 1 1
      tests/Monolog/Handler/FilterHandlerTest.php
  89. 6 6
      tests/Monolog/Handler/GelfHandlerTest.php
  90. 3 3
      tests/Monolog/Handler/GroupHandlerTest.php
  91. 1 1
      tests/Monolog/Handler/MailHandlerTest.php
  92. 1 1
      tests/Monolog/Handler/MongoDBHandlerTest.php
  93. 3 3
      tests/Monolog/Handler/NewRelicHandlerTest.php
  94. 5 5
      tests/Monolog/Handler/Slack/SlackRecordTest.php
  95. 1 1
      tests/Monolog/Handler/SlackWebhookHandlerTest.php
  96. 4 4
      tests/Monolog/Handler/WhatFailureGroupHandlerTest.php
  97. 4 4
      tests/Monolog/Handler/ZendMonitorHandlerTest.php
  98. 12 12
      tests/Monolog/LoggerTest.php
  99. 2 2
      tests/Monolog/Processor/GitProcessorTest.php
  100. 4 4
      tests/Monolog/Processor/HostnameProcessorTest.php

+ 6 - 6
doc/01-usage.md

@@ -140,7 +140,7 @@ write a processor adding some dummy data in the record:
 <?php
 
 $logger->pushProcessor(function ($record) {
-    $record['extra']['dummy'] = 'Hello world!';
+    $record->extra['dummy'] = 'Hello world!';
 
     return $record;
 });
@@ -190,23 +190,23 @@ $securityLogger = $logger->withName('security');
 ## Customizing the log format
 
 In Monolog it's easy to customize the format of the logs written into files,
-sockets, mails, databases and other handlers; by the use of "Formatters". 
+sockets, mails, databases and other handlers; by the use of "Formatters".
 
 As mentioned before, a *Formatter* is attached to a *Handler*, and as a general convention, most of the handlers use the
 ```php
-$record['formatted']
+$record->formatted
 ```
 field in the log record to store its formatted value. Again, this field depends on the implementation of the *Handler* but is a good idea to **stick into the good practices and conventions of the project**.
 
 You can choose between predefined formatter classes or write your own (e.g. a multiline text file for human-readable output).
 
 > Note:
-> 
+>
 > A very useful formatter to look at, is the `LineFormatter`.
-> 
+>
 > This formatter, as its name might indicate, is able to return a lineal string representation of the log record provided.
 > 
-> It is also capable to interpolate values from the log record, into the output format template used by the formatter to generate the final result, and in order to do it, you need to provide the log record values you are interested in, in the output template string using the form %value%, e.g: "'%context.foo% => %extra.foo%'", in this example the values $record["context"]["foo"] and $record["extra"]["foo"] will be rendered as part of the final result. 
+> It is also capable to interpolate values from the log record, into the output format template used by the formatter to generate the final result, and in order to do it, you need to provide the log record values you are interested in, in the output template string using the form %value%, e.g: "'%context.foo% => %extra.foo%'" , in this example the values $record->context["foo"] and $record->extra["foo"] will be rendered as part of th final result.
 
 In the following example, we demonstrate how to:
 1. Create a `LineFormatter` instance and set a custom output format template.

+ 5 - 5
doc/04-extending.md

@@ -43,10 +43,10 @@ class PDOHandler extends AbstractProcessingHandler
         }
 
         $this->statement->execute(array(
-            'channel' => $record['channel'],
-            'level' => $record['level'],
-            'message' => $record['formatted'],
-            'time' => $record['datetime']->format('U'),
+            'channel' => $record->channel,
+            'level' => $record->level,
+            'message' => $record->formatted,
+            'time' => $record->datetime->format('U'),
         ));
     }
 
@@ -78,6 +78,6 @@ $logger->info('My logger is now ready');
 
 The `Monolog\Handler\AbstractProcessingHandler` class provides most of the
 logic needed for the handler, including the use of processors and the formatting
-of the record (which is why we use ``$record['formatted']`` instead of ``$record['message']``).
+of the record (which is why we use ``$record->formatted`` instead of ``$record->message``).
 
 &larr; [Utility classes](03-utilities.md)

+ 10 - 10
src/Monolog/Formatter/ChromePHPFormatter.php

@@ -44,27 +44,27 @@ class ChromePHPFormatter implements FormatterInterface
     {
         // Retrieve the line and file if set and remove them from the formatted extra
         $backtrace = 'unknown';
-        if (isset($record['extra']['file'], $record['extra']['line'])) {
-            $backtrace = $record['extra']['file'].' : '.$record['extra']['line'];
-            unset($record['extra']['file'], $record['extra']['line']);
+        if (isset($record->extra['file'], $record->extra['line'])) {
+            $backtrace = $record->extra['file'].' : '.$record->extra['line'];
+            unset($record->extra['file'], $record->extra['line']);
         }
 
-        $message = ['message' => $record['message']];
-        if ($record['context']) {
-            $message['context'] = $record['context'];
+        $message = ['message' => $record->message];
+        if ($record->context) {
+            $message['context'] = $record->context;
         }
-        if ($record['extra']) {
-            $message['extra'] = $record['extra'];
+        if ($record->extra) {
+            $message['extra'] = $record->extra;
         }
         if (count($message) === 1) {
             $message = reset($message);
         }
 
         return [
-            $record['channel'],
+            $record->channel,
             $message,
             $backtrace,
-            $this->logLevels[$record['level']],
+            $this->logLevels[$record->level],
         ];
     }
 

+ 6 - 6
src/Monolog/Formatter/FlowdockFormatter.php

@@ -45,26 +45,26 @@ class FlowdockFormatter implements FormatterInterface
     {
         $tags = [
             '#logs',
-            '#' . strtolower($record['level_name']),
-            '#' . $record['channel'],
+            '#' . strtolower($record->levelName),
+            '#' . $record->channel,
         ];
 
-        foreach ($record['extra'] as $value) {
+        foreach ($record->extra as $value) {
             $tags[] = '#' . $value;
         }
 
         $subject = sprintf(
             'in %s: %s - %s',
             $this->source,
-            $record['level_name'],
-            $this->getShortMessage($record['message'])
+            $record->levelName,
+            $this->getShortMessage($record->message)
         );
 
         return [
             'source' => $this->source,
             'from_address' => $this->sourceEmail,
             'subject' => $subject,
-            'content' => $record['message'],
+            'content' => $record->message,
             'tags' => $tags,
             'project' => $this->source,
         ];

+ 8 - 8
src/Monolog/Formatter/FluentdFormatter.php

@@ -58,23 +58,23 @@ class FluentdFormatter implements FormatterInterface
 
     public function format(LogRecord $record): string
     {
-        $tag = $record['channel'];
+        $tag = $record->channel;
         if ($this->levelTag) {
-            $tag .= '.' . strtolower($record['level_name']);
+            $tag .= '.' . strtolower($record->levelName);
         }
 
         $message = [
-            'message' => $record['message'],
-            'context' => $record['context'],
-            'extra' => $record['extra'],
+            'message' => $record->message,
+            'context' => $record->context,
+            'extra' => $record->extra,
         ];
 
         if (!$this->levelTag) {
-            $message['level'] = $record['level'];
-            $message['level_name'] = $record['level_name'];
+            $message['level'] = $record->level;
+            $message['level_name'] = $record->levelName;
         }
 
-        return Utils::jsonEncode([$tag, $record['datetime']->getTimestamp(), $message]);
+        return Utils::jsonEncode([$tag, $record->datetime->getTimestamp(), $message]);
     }
 
     public function formatBatch(array $records): string

+ 11 - 11
src/Monolog/Formatter/GelfMessageFormatter.php

@@ -87,31 +87,31 @@ class GelfMessageFormatter extends NormalizerFormatter
     public function format(LogRecord $record): Message
     {
         $context = $extra = [];
-        if (isset($record['context'])) {
+        if (isset($record->context)) {
             /** @var mixed[] $context */
-            $context = parent::normalize($record['context']);
+            $context = parent::normalize($record->context);
         }
-        if (isset($record['extra'])) {
+        if (isset($record->extra)) {
             /** @var mixed[] $extra */
-            $extra = parent::normalize($record['extra']);
+            $extra = parent::normalize($record->extra);
         }
 
         $message = new Message();
         $message
-            ->setTimestamp($record['datetime'])
-            ->setShortMessage((string) $record['message'])
+            ->setTimestamp($record->datetime)
+            ->setShortMessage((string) $record->message)
             ->setHost($this->systemName)
-            ->setLevel($this->logLevels[$record['level']]);
+            ->setLevel($this->logLevels[$record->level]);
 
         // message length + system name length + 200 for padding / metadata
-        $len = 200 + strlen((string) $record['message']) + strlen($this->systemName);
+        $len = 200 + strlen((string) $record->message) + strlen($this->systemName);
 
         if ($len > $this->maxLength) {
-            $message->setShortMessage(Utils::substr($record['message'], 0, $this->maxLength));
+            $message->setShortMessage(Utils::substr($record->message, 0, $this->maxLength));
         }
 
-        if (isset($record['channel'])) {
-            $message->setFacility($record['channel']);
+        if (isset($record->channel)) {
+            $message->setFacility($record->channel);
         }
         if (isset($extra['line'])) {
             $message->setLine($extra['line']);

+ 8 - 8
src/Monolog/Formatter/HtmlFormatter.php

@@ -86,23 +86,23 @@ class HtmlFormatter extends NormalizerFormatter
      */
     public function format(LogRecord $record): string
     {
-        $output = $this->addTitle($record['level_name'], $record['level']);
+        $output = $this->addTitle($record->levelName, $record->level);
         $output .= '<table cellspacing="1" width="100%" class="monolog-output">';
 
-        $output .= $this->addRow('Message', (string) $record['message']);
-        $output .= $this->addRow('Time', $this->formatDate($record['datetime']));
-        $output .= $this->addRow('Channel', $record['channel']);
-        if ($record['context']) {
+        $output .= $this->addRow('Message', (string) $record->message);
+        $output .= $this->addRow('Time', $this->formatDate($record->datetime));
+        $output .= $this->addRow('Channel', $record->channel);
+        if ($record->context) {
             $embeddedTable = '<table cellspacing="1" width="100%">';
-            foreach ($record['context'] as $key => $value) {
+            foreach ($record->context as $key => $value) {
                 $embeddedTable .= $this->addRow((string) $key, $this->convertToString($value));
             }
             $embeddedTable .= '</table>';
             $output .= $this->addRow('Context', $embeddedTable, false);
         }
-        if ($record['extra']) {
+        if ($record->extra) {
             $embeddedTable = '<table cellspacing="1" width="100%">';
-            foreach ($record['extra'] as $key => $value) {
+            foreach ($record->extra as $key => $value) {
                 $embeddedTable .= $this->addRow((string) $key, $this->convertToString($value));
             }
             $embeddedTable .= '</table>';

+ 9 - 11
src/Monolog/Formatter/JsonFormatter.php

@@ -20,8 +20,6 @@ use Monolog\LogRecord;
  * This can be useful to log to databases or remote APIs
  *
  * @author Jordi Boggiano <j.boggiano@seld.be>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  */
 class JsonFormatter extends NormalizerFormatter
 {
@@ -29,13 +27,13 @@ class JsonFormatter extends NormalizerFormatter
     public const BATCH_MODE_NEWLINES = 2;
 
     /** @var self::BATCH_MODE_* */
-    protected $batchMode;
-    /** @var bool */
-    protected $appendNewline;
-    /** @var bool */
-    protected $ignoreEmptyContextAndExtra;
-    /** @var bool */
-    protected $includeStacktraces = false;
+    protected int $batchMode;
+
+    protected bool $appendNewline;
+
+    protected bool $ignoreEmptyContextAndExtra;
+
+    protected bool $includeStacktraces = false;
 
     /**
      * @param self::BATCH_MODE_* $batchMode
@@ -123,7 +121,7 @@ class JsonFormatter extends NormalizerFormatter
     /**
      * Return a JSON-encoded array of records.
      *
-     * @phpstan-param Record[] $records
+     * @phpstan-param LogRecord[] $records
      */
     protected function formatBatchJson(array $records): string
     {
@@ -134,7 +132,7 @@ class JsonFormatter extends NormalizerFormatter
      * Use new lines to separate records instead of a
      * JSON-encoded array.
      *
-     * @phpstan-param Record[] $records
+     * @phpstan-param LogRecord[] $records
      */
     protected function formatBatchNewlines(array $records): string
     {

+ 17 - 17
src/Monolog/Formatter/LogstashFormatter.php

@@ -65,37 +65,37 @@ class LogstashFormatter extends NormalizerFormatter
      */
     public function format(LogRecord $record): string
     {
-        $record = parent::format($record);
+        $recordData = parent::format($record);
 
-        if (empty($record['datetime'])) {
-            $record['datetime'] = gmdate('c');
+        if (empty($recordData['datetime'])) {
+            $recordData['datetime'] = gmdate('c');
         }
         $message = [
-            '@timestamp' => $record['datetime'],
+            '@timestamp' => $recordData['datetime'],
             '@version' => 1,
             'host' => $this->systemName,
         ];
-        if (isset($record['message'])) {
-            $message['message'] = $record['message'];
+        if (isset($recordData['message'])) {
+            $message['message'] = $recordData['message'];
         }
-        if (isset($record['channel'])) {
-            $message['type'] = $record['channel'];
-            $message['channel'] = $record['channel'];
+        if (isset($recordData['channel'])) {
+            $message['type'] = $recordData['channel'];
+            $message['channel'] = $recordData['channel'];
         }
-        if (isset($record['level_name'])) {
-            $message['level'] = $record['level_name'];
+        if (isset($recordData['level_name'])) {
+            $message['level'] = $recordData['level_name'];
         }
-        if (isset($record['level'])) {
-            $message['monolog_level'] = $record['level'];
+        if (isset($recordData['level'])) {
+            $message['monolog_level'] = $recordData['level'];
         }
         if ($this->applicationName) {
             $message['type'] = $this->applicationName;
         }
-        if (!empty($record['extra'])) {
-            $message[$this->extraKey] = $record['extra'];
+        if (!empty($recordData['extra'])) {
+            $message[$this->extraKey] = $recordData['extra'];
         }
-        if (!empty($record['context'])) {
-            $message[$this->contextKey] = $record['context'];
+        if (!empty($recordData['context'])) {
+            $message[$this->contextKey] = $recordData['context'];
         }
 
         return $this->toJson($message) . "\n";

+ 1 - 1
src/Monolog/Formatter/MongoDBFormatter.php

@@ -31,7 +31,7 @@ class MongoDBFormatter implements FormatterInterface
     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
      * @param bool $exceptionTraceAsString set to false to log exception traces as a sub documents instead of strings
      */
     public function __construct(int $maxNestingLevel = 3, bool $exceptionTraceAsString = true)

+ 16 - 16
src/Monolog/Formatter/WildfireFormatter.php

@@ -61,38 +61,38 @@ class WildfireFormatter extends NormalizerFormatter
     {
         // Retrieve the line and file if set and remove them from the formatted extra
         $file = $line = '';
-        if (isset($record['extra']['file'])) {
-            $file = $record['extra']['file'];
-            unset($record['extra']['file']);
+        if (isset($record->extra['file'])) {
+            $file = $record->extra['file'];
+            unset($record->extra['file']);
         }
-        if (isset($record['extra']['line'])) {
-            $line = $record['extra']['line'];
-            unset($record['extra']['line']);
+        if (isset($record->extra['line'])) {
+            $line = $record->extra['line'];
+            unset($record->extra['line']);
         }
 
         /** @var mixed[] $record */
         $record = $this->normalize($record);
-        $message = ['message' => $record['message']];
+        $message = ['message' => $record->message];
         $handleError = false;
-        if ($record['context']) {
-            $message['context'] = $record['context'];
+        if ($record->context) {
+            $message['context'] = $record->context;
             $handleError = true;
         }
-        if ($record['extra']) {
-            $message['extra'] = $record['extra'];
+        if ($record->extra) {
+            $message['extra'] = $record->extra;
             $handleError = true;
         }
         if (count($message) === 1) {
             $message = reset($message);
         }
 
-        if (isset($record['context']['table'])) {
+        if (isset($record->context['table'])) {
             $type  = 'TABLE';
-            $label = $record['channel'] .': '. $record['message'];
-            $message = $record['context']['table'];
+            $label = $record->channel .': '. $record->message;
+            $message = $record->context['table'];
         } else {
-            $type  = $this->logLevels[$record['level']];
-            $label = $record['channel'];
+            $type  = $this->logLevels[$record->level];
+            $label = $record->channel;
         }
 
         // Create JSON object describing the appearance of the message in the console

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

@@ -51,7 +51,7 @@ abstract class AbstractHandler extends Handler implements ResettableInterface
      */
     public function isHandling(LogRecord $record): bool
     {
-        return $record['level'] >= $this->level;
+        return $record->level >= $this->level;
     }
 
     /**

+ 2 - 6
src/Monolog/Handler/AbstractProcessingHandler.php

@@ -23,8 +23,6 @@ use Monolog\LogRecord;
  *
  * @phpstan-import-type LevelName from \Monolog\Logger
  * @phpstan-import-type Level from \Monolog\Logger
- * @phpstan-import-type Record from \Monolog\Logger
- * @phpstan-type FormattedRecord array{message: string, context: mixed[], level: Level, level_name: LevelName, channel: string, datetime: \DateTimeImmutable, extra: mixed[], formatted: mixed}
  */
 abstract class AbstractProcessingHandler extends AbstractHandler implements ProcessableHandlerInterface, FormattableHandlerInterface
 {
@@ -44,7 +42,7 @@ abstract class AbstractProcessingHandler extends AbstractHandler implements Proc
             $record = $this->processRecord($record);
         }
 
-        $record['formatted'] = $this->getFormatter()->format($record);
+        $record->formatted = $this->getFormatter()->format($record);
 
         $this->write($record);
 
@@ -52,9 +50,7 @@ abstract class AbstractProcessingHandler extends AbstractHandler implements Proc
     }
 
     /**
-     * Writes the record down to the log of the implementing handler
-     *
-     * @phpstan-param FormattedRecord $record
+     * Writes the (already formatted) record down to the log of the implementing handler
      */
     abstract protected function write(LogRecord $record): void;
 

+ 2 - 8
src/Monolog/Handler/AmqpHandler.php

@@ -19,9 +19,6 @@ use PhpAmqpLib\Channel\AMQPChannel;
 use AMQPExchange;
 use Monolog\LogRecord;
 
-/**
- * @phpstan-import-type Record from \Monolog\Logger
- */
 class AmqpHandler extends AbstractProcessingHandler
 {
     /**
@@ -57,7 +54,7 @@ class AmqpHandler extends AbstractProcessingHandler
      */
     protected function write(LogRecord $record): void
     {
-        $data = $record["formatted"];
+        $data = $record->formatted;
         $routingKey = $this->getRoutingKey($record);
 
         if ($this->exchange instanceof AMQPExchange) {
@@ -95,7 +92,6 @@ class AmqpHandler extends AbstractProcessingHandler
                 continue;
             }
 
-            /** @var Record $record */
             $record = $this->processRecord($record);
             $data = $this->getFormatter()->format($record);
 
@@ -111,12 +107,10 @@ class AmqpHandler extends AbstractProcessingHandler
 
     /**
      * Gets the routing key for the AMQP exchange
-     *
-     * @phpstan-param Record $record
      */
     protected function getRoutingKey(LogRecord $record): string
     {
-        $routingKey = sprintf('%s.%s', $record['level_name'], $record['channel']);
+        $routingKey = sprintf('%s.%s', $record->levelName, $record->channel);
 
         return strtolower($routingKey);
     }

+ 16 - 18
src/Monolog/Handler/BrowserConsoleHandler.php

@@ -27,15 +27,13 @@ use const E_USER_DEPRECATED;
  * Handler sending logs to browser's javascript console with no browser extension required
  *
  * @author Olivier Poitrey <rs@dailymotion.com>
- *
- * @phpstan-import-type FormattedRecord from AbstractProcessingHandler
  */
 class BrowserConsoleHandler extends AbstractProcessingHandler
 {
-    /** @var bool */
-    protected static $initialized = false;
-    /** @var FormattedRecord[] */
-    protected static $records = [];
+    protected static bool $initialized = false;
+
+    /** @var LogRecord[] */
+    protected static array $records = [];
 
     protected const FORMAT_HTML = 'html';
     protected const FORMAT_JS = 'js';
@@ -174,18 +172,18 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
     {
         $script = [];
         foreach (static::$records as $record) {
-            $context = static::dump('Context', $record['context']);
-            $extra = static::dump('Extra', $record['extra']);
+            $context = self::dump('Context', $record->context);
+            $extra = self::dump('Extra', $record->extra);
 
             if (empty($context) && empty($extra)) {
-                $script[] = static::call_array('log', static::handleStyles($record['formatted']));
+                $script[] = self::call_array('log', self::handleStyles($record->formatted));
             } else {
                 $script = array_merge(
                     $script,
-                    [static::call_array('groupCollapsed', static::handleStyles($record['formatted']))],
+                    [self::call_array('groupCollapsed', self::handleStyles($record->formatted))],
                     $context,
                     $extra,
-                    [static::call('groupEnd')]
+                    [self::call('groupEnd')]
                 );
             }
         }
@@ -204,14 +202,14 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
 
         foreach (array_reverse($matches) as $match) {
             $args[] = '"font-weight: normal"';
-            $args[] = static::quote(static::handleCustomStyles($match[2][0], $match[1][0]));
+            $args[] = self::quote(static::handleCustomStyles($match[2][0], $match[1][0]));
 
             $pos = $match[0][1];
             $format = Utils::substr($format, 0, $pos) . '%c' . $match[1][0] . '%c' . Utils::substr($format, $pos + strlen($match[0][0]));
         }
 
-        $args[] = static::quote('font-weight: normal');
-        $args[] = static::quote($format);
+        $args[] = self::quote('font-weight: normal');
+        $args[] = self::quote($format);
 
         return array_reverse($args);
     }
@@ -254,13 +252,13 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
         if (empty($dict)) {
             return $script;
         }
-        $script[] = static::call('log', static::quote('%c%s'), static::quote('font-weight: bold'), static::quote($title));
+        $script[] = self::call('log', self::quote('%c%s'), self::quote('font-weight: bold'), self::quote($title));
         foreach ($dict as $key => $value) {
             $value = json_encode($value);
             if (empty($value)) {
-                $value = static::quote('');
+                $value = self::quote('');
             }
-            $script[] = static::call('log', static::quote('%s: %o'), static::quote((string) $key), $value);
+            $script[] = self::call('log', self::quote('%s: %o'), self::quote((string) $key), $value);
         }
 
         return $script;
@@ -281,7 +279,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
             throw new \UnexpectedValueException('Expected the first arg to be a string, got: '.var_export($method, true));
         }
 
-        return static::call_array($method, $args);
+        return self::call_array($method, $args);
     }
 
     /**

+ 13 - 16
src/Monolog/Handler/BufferHandler.php

@@ -23,25 +23,23 @@ use Monolog\LogRecord;
  * sending one per log message.
  *
  * @author Christophe Coevoet <stof@notk.org>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  */
 class BufferHandler extends AbstractHandler implements ProcessableHandlerInterface, FormattableHandlerInterface
 {
     use ProcessableHandlerTrait;
 
-    /** @var HandlerInterface */
-    protected $handler;
-    /** @var int */
-    protected $bufferSize = 0;
-    /** @var int */
-    protected $bufferLimit;
-    /** @var bool */
-    protected $flushOnOverflow;
-    /** @var Record[] */
-    protected $buffer = [];
-    /** @var bool */
-    protected $initialized = false;
+    protected HandlerInterface $handler;
+
+    protected int $bufferSize = 0;
+
+    protected int $bufferLimit;
+
+    protected bool $flushOnOverflow;
+
+    /** @var LogRecord[] */
+    protected array $buffer = [];
+
+    protected bool $initialized = false;
 
     /**
      * @param HandlerInterface $handler         Handler.
@@ -61,7 +59,7 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
      */
     public function handle(LogRecord $record): bool
     {
-        if ($record['level'] < $this->level) {
+        if ($record->level < $this->level) {
             return false;
         }
 
@@ -81,7 +79,6 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
         }
 
         if ($this->processors) {
-            /** @var Record $record */
             $record = $this->processRecord($record);
         }
 

+ 3 - 5
src/Monolog/Handler/ChromePHPHandler.php

@@ -24,8 +24,6 @@ use Monolog\DateTimeImmutable;
  * This also works out of the box with Firefox 43+
  *
  * @author Christophe Coevoet <stof@notk.org>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  */
 class ChromePHPHandler extends AbstractProcessingHandler
 {
@@ -88,10 +86,10 @@ class ChromePHPHandler extends AbstractProcessingHandler
         $messages = [];
 
         foreach ($records as $record) {
-            if ($record['level'] < $this->level) {
+            if ($record->level < $this->level) {
                 continue;
             }
-            /** @var Record $message */
+
             $message = $this->processRecord($record);
             $messages[] = $message;
         }
@@ -123,7 +121,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
             return;
         }
 
-        self::$json['rows'][] = $record['formatted'];
+        self::$json['rows'][] = $record->formatted;
 
         $this->send();
     }

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

@@ -56,7 +56,7 @@ class CouchDBHandler extends AbstractProcessingHandler
         $context = stream_context_create([
             'http' => [
                 'method'        => 'POST',
-                'content'       => $record['formatted'],
+                'content'       => $record->formatted,
                 'ignore_errors' => true,
                 'max_redirects' => 0,
                 'header'        => 'Content-type: application/json',

+ 8 - 8
src/Monolog/Handler/CubeHandler.php

@@ -115,20 +115,20 @@ class CubeHandler extends AbstractProcessingHandler
      */
     protected function write(LogRecord $record): void
     {
-        $date = $record['datetime'];
+        $date = $record->datetime;
 
         $data = ['time' => $date->format('Y-m-d\TH:i:s.uO')];
-        unset($record['datetime']);
+        unset($record->datetime);
 
-        if (isset($record['context']['type'])) {
-            $data['type'] = $record['context']['type'];
-            unset($record['context']['type']);
+        if (isset($record->context['type'])) {
+            $data['type'] = $record->context['type'];
+            unset($record->context['type']);
         } else {
-            $data['type'] = $record['channel'];
+            $data['type'] = $record->channel;
         }
 
-        $data['data'] = $record['context'];
-        $data['data']['level'] = $record['level'];
+        $data['data'] = $record->context;
+        $data['data']['level'] = $record->level;
 
         if ($this->scheme === 'http') {
             $this->writeHttp(Utils::jsonEncode($data));

+ 1 - 1
src/Monolog/Handler/Curl/Util.php

@@ -34,7 +34,7 @@ final class Util
     /**
      * Executes a CURL request with optional retries and exception on failure
      *
-     * @param  resource|CurlHandle $ch             curl handler
+     * @param  CurlHandle $ch             curl handler
      * @param  int                 $retries
      * @param  bool                $closeAfterDone
      * @return bool|string         @see curl_exec

+ 5 - 13
src/Monolog/Handler/DeduplicationHandler.php

@@ -34,8 +34,6 @@ use Monolog\LogRecord;
  * same way.
  *
  * @author Jordi Boggiano <j.boggiano@seld.be>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  * @phpstan-import-type LevelName from \Monolog\Logger
  * @phpstan-import-type Level from \Monolog\Logger
  */
@@ -88,7 +86,7 @@ class DeduplicationHandler extends BufferHandler
         $passthru = null;
 
         foreach ($this->buffer as $record) {
-            if ($record['level'] >= $this->deduplicationLevel) {
+            if ($record->level >= $this->deduplicationLevel) {
                 $passthru = $passthru || !$this->isDuplicate($record);
                 if ($passthru) {
                     $this->appendRecord($record);
@@ -108,9 +106,6 @@ class DeduplicationHandler extends BufferHandler
         }
     }
 
-    /**
-     * @phpstan-param Record $record
-     */
     private function isDuplicate(LogRecord $record): bool
     {
         if (!file_exists($this->deduplicationStore)) {
@@ -123,13 +118,13 @@ class DeduplicationHandler extends BufferHandler
         }
 
         $yesterday = time() - 86400;
-        $timestampValidity = $record['datetime']->getTimestamp() - $this->time;
-        $expectedMessage = preg_replace('{[\r\n].*}', '', $record['message']);
+        $timestampValidity = $record->datetime->getTimestamp() - $this->time;
+        $expectedMessage = preg_replace('{[\r\n].*}', '', $record->message);
 
         for ($i = count($store) - 1; $i >= 0; $i--) {
             list($timestamp, $level, $message) = explode(':', $store[$i], 3);
 
-            if ($level === $record['level_name'] && $message === $expectedMessage && $timestamp > $timestampValidity) {
+            if ($level === $record->levelName && $message === $expectedMessage && $timestamp > $timestampValidity) {
                 return true;
             }
 
@@ -177,11 +172,8 @@ class DeduplicationHandler extends BufferHandler
         $this->gc = false;
     }
 
-    /**
-     * @phpstan-param Record $record
-     */
     private function appendRecord(LogRecord $record): void
     {
-        file_put_contents($this->deduplicationStore, $record['datetime']->getTimestamp() . ':' . $record['level_name'] . ':' . preg_replace('{[\r\n].*}', '', $record['message']) . "\n", FILE_APPEND);
+        file_put_contents($this->deduplicationStore, $record->datetime->getTimestamp() . ':' . $record->levelName . ':' . preg_replace('{[\r\n].*}', '', $record->message) . "\n", FILE_APPEND);
     }
 }

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

@@ -38,7 +38,7 @@ class DoctrineCouchDBHandler extends AbstractProcessingHandler
      */
     protected function write(LogRecord $record): void
     {
-        $this->client->postDocument($record['formatted']);
+        $this->client->postDocument($record->formatted);
     }
 
     protected function getDefaultFormatter(): FormatterInterface

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

@@ -70,7 +70,7 @@ class DynamoDbHandler extends AbstractProcessingHandler
      */
     protected function write(LogRecord $record): void
     {
-        $filtered = $this->filterEmptyFields($record['formatted']);
+        $filtered = $this->filterEmptyFields($record->formatted);
         if ($this->version === 3) {
             $formatted = $this->marshaler->marshalItem($filtered);
         } else {

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

@@ -70,7 +70,7 @@ class ElasticaHandler extends AbstractProcessingHandler
      */
     protected function write(LogRecord $record): void
     {
-        $this->bulkSend([$record['formatted']]);
+        $this->bulkSend([$record->formatted]);
     }
 
     /**

+ 2 - 2
src/Monolog/Handler/ElasticsearchHandler.php

@@ -77,7 +77,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
      */
     protected function write(LogRecord $record): void
     {
-        $this->bulkSend([$record['formatted']]);
+        $this->bulkSend([$record->formatted]);
     }
 
     /**
@@ -122,7 +122,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
     /**
      * Use Elasticsearch bulk API to send list of documents
      *
-     * @param  array[]           $records Records + _index/_type keys
+     * @param  array<array<mixed>> $records Records + _index/_type keys
      * @throws \RuntimeException
      */
     protected function bulkSend(array $records): void

+ 2 - 2
src/Monolog/Handler/ErrorLogHandler.php

@@ -75,12 +75,12 @@ class ErrorLogHandler extends AbstractProcessingHandler
     protected function write(LogRecord $record): void
     {
         if (!$this->expandNewlines) {
-            error_log((string) $record['formatted'], $this->messageType);
+            error_log((string) $record->formatted, $this->messageType);
 
             return;
         }
 
-        $lines = preg_split('{[\r\n]+}', (string) $record['formatted']);
+        $lines = preg_split('{[\r\n]+}', (string) $record->formatted);
         if ($lines === false) {
             $pcreErrorCode = preg_last_error();
             throw new \RuntimeException('Failed to preg_split formatted string: ' . $pcreErrorCode . ' / '. Utils::pcreLastErrorMessage($pcreErrorCode));

+ 0 - 4
src/Monolog/Handler/FallbackGroupHandler.php

@@ -20,8 +20,6 @@ use Monolog\LogRecord;
  * If a handler fails, the exception is suppressed and the record is forwarded to the next handler.
  *
  * As soon as one handler handles a record successfully, the handling stops there.
- *
- * @phpstan-import-type Record from \Monolog\Logger
  */
 class FallbackGroupHandler extends GroupHandler
 {
@@ -31,7 +29,6 @@ class FallbackGroupHandler extends GroupHandler
     public function handle(LogRecord $record): bool
     {
         if ($this->processors) {
-            /** @var Record $record */
             $record = $this->processRecord($record);
         }
         foreach ($this->handlers as $handler) {
@@ -56,7 +53,6 @@ class FallbackGroupHandler extends GroupHandler
             foreach ($records as $record) {
                 $processed[] = $this->processRecord($record);
             }
-            /** @var Record[] $records */
             $records = $processed;
         }
 

+ 3 - 8
src/Monolog/Handler/FilterHandler.php

@@ -24,8 +24,6 @@ use Monolog\LogRecord;
  *
  * @author Hennadiy Verkh
  * @author Jordi Boggiano <j.boggiano@seld.be>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  * @phpstan-import-type Level from \Monolog\Logger
  * @phpstan-import-type LevelName from \Monolog\Logger
  */
@@ -37,7 +35,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
      * Handler or factory callable($record, $this)
      *
      * @var callable|HandlerInterface
-     * @phpstan-var callable(?Record, HandlerInterface): HandlerInterface|HandlerInterface
+     * @phpstan-var (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface
      */
     protected $handler;
 
@@ -57,7 +55,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
     protected $bubble;
 
     /**
-     * @psalm-param HandlerInterface|callable(?Record, HandlerInterface): HandlerInterface $handler
+     * @phpstan-param (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler
      *
      * @param callable|HandlerInterface $handler        Handler or factory callable($record|null, $filterHandler).
      * @param int|array                 $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided
@@ -114,7 +112,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
      */
     public function isHandling(LogRecord $record): bool
     {
-        return isset($this->acceptedLevels[$record['level']]);
+        return isset($this->acceptedLevels[$record->level]);
     }
 
     /**
@@ -127,7 +125,6 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
         }
 
         if ($this->processors) {
-            /** @var Record $record */
             $record = $this->processRecord($record);
         }
 
@@ -159,8 +156,6 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
      * If the handler was provided as a factory callable, this will trigger the handler's instantiation.
      *
      * @return HandlerInterface
-     *
-     * @phpstan-param Record $record
      */
     public function getHandler(LogRecord $record = null)
     {

+ 0 - 4
src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php

@@ -17,15 +17,11 @@ use Monolog\LogRecord;
  * Interface for activation strategies for the FingersCrossedHandler.
  *
  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  */
 interface ActivationStrategyInterface
 {
     /**
      * Returns whether the given record activates the handler.
-     *
-     * @phpstan-param Record $record
      */
     public function isHandlerActivated(LogRecord $record): bool;
 }

+ 3 - 8
src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php

@@ -34,8 +34,6 @@ use Monolog\LogRecord;
  * </code>
  *
  * @author Mike Meessen <netmikey@gmail.com>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  * @phpstan-import-type Level from \Monolog\Logger
  * @phpstan-import-type LevelName from \Monolog\Logger
  */
@@ -64,15 +62,12 @@ class ChannelLevelActivationStrategy implements ActivationStrategyInterface
         $this->channelToActionLevel = array_map('Monolog\Logger::toMonologLevel', $channelToActionLevel);
     }
 
-    /**
-     * @phpstan-param Record $record
-     */
     public function isHandlerActivated(LogRecord $record): bool
     {
-        if (isset($this->channelToActionLevel[$record['channel']])) {
-            return $record['level'] >= $this->channelToActionLevel[$record['channel']];
+        if (isset($this->channelToActionLevel[$record->channel])) {
+            return $record->level >= $this->channelToActionLevel[$record->channel];
         }
 
-        return $record['level'] >= $this->defaultActionLevel;
+        return $record->level >= $this->defaultActionLevel;
     }
 }

+ 1 - 1
src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php

@@ -42,6 +42,6 @@ class ErrorLevelActivationStrategy implements ActivationStrategyInterface
 
     public function isHandlerActivated(LogRecord $record): bool
     {
-        return $record['level'] >= $this->actionLevel;
+        return $record->level >= $this->actionLevel;
     }
 }

+ 4 - 9
src/Monolog/Handler/FingersCrossedHandler.php

@@ -34,8 +34,6 @@ use Monolog\LogRecord;
  * Monolog\Handler\FingersCrossed\ namespace.
  *
  * @author Jordi Boggiano <j.boggiano@seld.be>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  * @phpstan-import-type Level from \Monolog\Logger
  * @phpstan-import-type LevelName from \Monolog\Logger
  */
@@ -45,7 +43,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
 
     /**
      * @var callable|HandlerInterface
-     * @phpstan-var callable(?Record, HandlerInterface): HandlerInterface|HandlerInterface
+     * @phpstan-var (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface
      */
     protected $handler;
     /** @var ActivationStrategyInterface */
@@ -54,7 +52,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
     protected $buffering = true;
     /** @var int */
     protected $bufferSize;
-    /** @var Record[] */
+    /** @var LogRecord[] */
     protected $buffer = [];
     /** @var bool */
     protected $stopBuffering;
@@ -67,7 +65,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
     protected $bubble;
 
     /**
-     * @psalm-param HandlerInterface|callable(?Record, HandlerInterface): HandlerInterface $handler
+     * @phpstan-param (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler
      *
      * @param callable|HandlerInterface              $handler            Handler or factory callable($record|null, $fingersCrossedHandler).
      * @param int|string|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action, or a level name/value at which the handler is activated
@@ -132,7 +130,6 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
     public function handle(LogRecord $record): bool
     {
         if ($this->processors) {
-            /** @var Record $record */
             $record = $this->processRecord($record);
         }
 
@@ -191,7 +188,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
         if (null !== $this->passthruLevel) {
             $level = $this->passthruLevel;
             $this->buffer = array_filter($this->buffer, function ($record) use ($level) {
-                return $record['level'] >= $level;
+                return $record->level >= $level;
             });
             if (count($this->buffer) > 0) {
                 $this->getHandler(end($this->buffer))->handleBatch($this->buffer);
@@ -208,8 +205,6 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
      * If the handler was provided as a factory callable, this will trigger the handler's instantiation.
      *
      * @return HandlerInterface
-     *
-     * @phpstan-param Record $record
      */
     public function getHandler(LogRecord $record = null)
     {

+ 1 - 5
src/Monolog/Handler/FirePHPHandler.php

@@ -19,8 +19,6 @@ use Monolog\LogRecord;
  * Simple FirePHP Handler (http://www.firephp.org/), which uses the Wildfire protocol.
  *
  * @author Eric Clemmons (@ericclemmons) <eric@uxdriven.com>
- *
- * @phpstan-import-type FormattedRecord from AbstractProcessingHandler
  */
 class FirePHPHandler extends AbstractProcessingHandler
 {
@@ -86,8 +84,6 @@ class FirePHPHandler extends AbstractProcessingHandler
      * @phpstan-return non-empty-array<string, string>
      *
      * @see createHeader()
-     *
-     * @phpstan-param FormattedRecord $record
      */
     protected function createRecordHeader(LogRecord $record): array
     {
@@ -95,7 +91,7 @@ class FirePHPHandler extends AbstractProcessingHandler
         // but we're not taking advantage of that (yet), so we're using "1" for simplicity's sake.
         return $this->createHeader(
             [1, 1, 1, self::$messageIndex++],
-            $record['formatted']
+            $record->formatted
         );
     }
 

+ 1 - 5
src/Monolog/Handler/FleepHookHandler.php

@@ -23,8 +23,6 @@ use Monolog\LogRecord;
  *
  * @see https://fleep.io/integrations/webhooks/ Fleep Webhooks Documentation
  * @author Ando Roots <ando@sqroot.eu>
- *
- * @phpstan-import-type FormattedRecord from AbstractProcessingHandler
  */
 class FleepHookHandler extends SocketHandler
 {
@@ -122,13 +120,11 @@ class FleepHookHandler extends SocketHandler
 
     /**
      * Builds the body of API call
-     *
-     * @phpstan-param FormattedRecord $record
      */
     private function buildContent(LogRecord $record): string
     {
         $dataArray = [
-            'message' => $record['formatted'],
+            'message' => $record->formatted,
         ];
 
         return http_build_query($dataArray);

+ 1 - 5
src/Monolog/Handler/FlowdockHandler.php

@@ -27,8 +27,6 @@ use Monolog\LogRecord;
  *
  * @author Dominik Liebler <liebler.dominik@gmail.com>
  * @see https://www.flowdock.com/api/push
- *
- * @phpstan-import-type FormattedRecord from AbstractProcessingHandler
  */
 class FlowdockHandler extends SocketHandler
 {
@@ -109,12 +107,10 @@ class FlowdockHandler extends SocketHandler
 
     /**
      * Builds the body of API call
-     *
-     * @phpstan-param FormattedRecord $record
      */
     private function buildContent(LogRecord $record): string
     {
-        return Utils::jsonEncode($record['formatted']);
+        return Utils::jsonEncode($record->formatted);
     }
 
     /**

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

@@ -45,7 +45,7 @@ class GelfHandler extends AbstractProcessingHandler
      */
     protected function write(LogRecord $record): void
     {
-        $this->publisher->publish($record['formatted']);
+        $this->publisher->publish($record->formatted);
     }
 
     /**

+ 0 - 4
src/Monolog/Handler/GroupHandler.php

@@ -19,8 +19,6 @@ use Monolog\LogRecord;
  * Forwards records to multiple handlers
  *
  * @author Lenar Lõhmus <lenar@city.ee>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  */
 class GroupHandler extends Handler implements ProcessableHandlerInterface, ResettableInterface
 {
@@ -67,7 +65,6 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface, Reset
     public function handle(LogRecord $record): bool
     {
         if ($this->processors) {
-            /** @var Record $record */
             $record = $this->processRecord($record);
         }
 
@@ -88,7 +85,6 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface, Reset
             foreach ($records as $record) {
                 $processed[] = $this->processRecord($record);
             }
-            /** @var Record[] $records */
             $records = $processed;
         }
 

+ 2 - 2
src/Monolog/Handler/IFTTTHandler.php

@@ -55,9 +55,9 @@ class IFTTTHandler extends AbstractProcessingHandler
     public function write(LogRecord $record): void
     {
         $postData = [
-            "value1" => $record["channel"],
+            "value1" => $record->channel,
             "value2" => $record["level_name"],
-            "value3" => $record["message"],
+            "value3" => $record->message,
         ];
         $postString = Utils::jsonEncode($postData);
 

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

@@ -72,6 +72,6 @@ class InsightOpsHandler extends SocketHandler
      */
     protected function generateDataStream(LogRecord $record): string
     {
-        return $this->logToken . ' ' . $record['formatted'];
+        return $this->logToken . ' ' . $record->formatted;
     }
 }

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

@@ -66,6 +66,6 @@ class LogEntriesHandler extends SocketHandler
      */
     protected function generateDataStream(LogRecord $record): string
     {
-        return $this->logToken . ' ' . $record['formatted'];
+        return $this->logToken . ' ' . $record->formatted;
     }
 }

+ 5 - 5
src/Monolog/Handler/LogglyHandler.php

@@ -34,7 +34,7 @@ class LogglyHandler extends AbstractProcessingHandler
     /**
      * Caches the curl handlers for every given endpoint.
      *
-     * @var resource[]|CurlHandle[]
+     * @var CurlHandle[]
      */
     protected $curlHandlers = [];
 
@@ -65,7 +65,7 @@ class LogglyHandler extends AbstractProcessingHandler
      *
      * @param string $endpoint
      *
-     * @return resource|CurlHandle
+     * @return CurlHandle
      */
     protected function getCurlHandler(string $endpoint)
     {
@@ -81,7 +81,7 @@ class LogglyHandler extends AbstractProcessingHandler
      *
      * @param string $endpoint
      *
-     * @return resource|CurlHandle
+     * @return CurlHandle
      */
     private function loadCurlHandle(string $endpoint)
     {
@@ -122,7 +122,7 @@ class LogglyHandler extends AbstractProcessingHandler
 
     protected function write(LogRecord $record): void
     {
-        $this->send($record["formatted"], static::ENDPOINT_SINGLE);
+        $this->send($record->formatted, static::ENDPOINT_SINGLE);
     }
 
     public function handleBatch(array $records): void
@@ -130,7 +130,7 @@ class LogglyHandler extends AbstractProcessingHandler
         $level = $this->level;
 
         $records = array_filter($records, function ($record) use ($level) {
-            return ($record['level'] >= $level);
+            return ($record->level >= $level);
         });
 
         if ($records) {

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

@@ -85,7 +85,7 @@ class LogmaticHandler extends SocketHandler
      */
     protected function generateDataStream(LogRecord $record): string
     {
-        return $this->logToken . ' ' . $record['formatted'];
+        return $this->logToken . ' ' . $record->formatted;
     }
 
     /**

+ 4 - 6
src/Monolog/Handler/MailHandler.php

@@ -19,8 +19,6 @@ use Monolog\LogRecord;
  * Base class for all mail handlers
  *
  * @author Gyula Sallai
- *
- * @phpstan-import-type Record from \Monolog\Logger
  */
 abstract class MailHandler extends AbstractProcessingHandler
 {
@@ -32,10 +30,10 @@ abstract class MailHandler extends AbstractProcessingHandler
         $messages = [];
 
         foreach ($records as $record) {
-            if ($record['level'] < $this->level) {
+            if ($record->level < $this->level) {
                 continue;
             }
-            /** @var Record $message */
+
             $message = $this->processRecord($record);
             $messages[] = $message;
         }
@@ -60,7 +58,7 @@ abstract class MailHandler extends AbstractProcessingHandler
      */
     protected function write(LogRecord $record): void
     {
-        $this->send((string) $record['formatted'], [$record]);
+        $this->send((string) $record->formatted, [$record]);
     }
 
     /**
@@ -70,7 +68,7 @@ abstract class MailHandler extends AbstractProcessingHandler
     {
         $highestRecord = null;
         foreach ($records as $record) {
-            if ($highestRecord === null || $highestRecord['level'] < $record['level']) {
+            if ($highestRecord === null || $highestRecord['level'] < $record->level) {
                 $highestRecord = $record;
             }
         }

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

@@ -28,7 +28,7 @@ class MandrillHandler extends MailHandler
     protected $apiKey;
 
     /**
-     * @psalm-param Swift_Message|callable(): Swift_Message $message
+     * @phpstan-param (Swift_Message|callable(): Swift_Message) $message
      *
      * @param string                 $apiKey  A valid Mandrill API key
      * @param callable|Swift_Message $message An example message for real messages, only the body will be replaced

+ 7 - 8
src/Monolog/Handler/MongoDBHandler.php

@@ -34,12 +34,11 @@ use Monolog\LogRecord;
  */
 class MongoDBHandler extends AbstractProcessingHandler
 {
-    /** @var \MongoDB\Collection */
-    private $collection;
-    /** @var Client|Manager */
-    private $manager;
-    /** @var string */
-    private $namespace;
+    private \MongoDB\Collection $collection;
+
+    private Client|Manager $manager;
+
+    private string|null $namespace = null;
 
     /**
      * Constructor.
@@ -67,12 +66,12 @@ class MongoDBHandler extends AbstractProcessingHandler
     protected function write(LogRecord $record): void
     {
         if (isset($this->collection)) {
-            $this->collection->insertOne($record['formatted']);
+            $this->collection->insertOne($record->formatted);
         }
 
         if (isset($this->manager, $this->namespace)) {
             $bulk = new BulkWrite;
-            $bulk->insert($record["formatted"]);
+            $bulk->insert($record->formatted);
             $this->manager->executeBulkWrite($this->namespace, $bulk);
         }
     }

+ 12 - 12
src/Monolog/Handler/NewRelicHandler.php

@@ -21,7 +21,7 @@ use Monolog\LogRecord;
  * Class to record a log on a NewRelic application.
  * Enabling New Relic High Security mode may prevent capture of useful information.
  *
- * This handler requires a NormalizerFormatter to function and expects an array in $record['formatted']
+ * This handler requires a NormalizerFormatter to function and expects an array in $record->formatted
  *
  * @see https://docs.newrelic.com/docs/agents/php-agent
  * @see https://docs.newrelic.com/docs/accounts-partnerships/accounts/security/high-security
@@ -80,24 +80,24 @@ class NewRelicHandler extends AbstractProcessingHandler
             throw new MissingExtensionException('The newrelic PHP extension is required to use the NewRelicHandler');
         }
 
-        if ($appName = $this->getAppName($record['context'])) {
+        if ($appName = $this->getAppName($record->context)) {
             $this->setNewRelicAppName($appName);
         }
 
-        if ($transactionName = $this->getTransactionName($record['context'])) {
+        if ($transactionName = $this->getTransactionName($record->context)) {
             $this->setNewRelicTransactionName($transactionName);
-            unset($record['formatted']['context']['transaction_name']);
+            unset($record->formatted['context']['transaction_name']);
         }
 
-        if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Throwable) {
-            newrelic_notice_error($record['message'], $record['context']['exception']);
-            unset($record['formatted']['context']['exception']);
+        if (isset($record->context['exception']) && $record->context['exception'] instanceof \Throwable) {
+            newrelic_notice_error($record->message, $record->context['exception']);
+            unset($record->formatted['context']['exception']);
         } else {
-            newrelic_notice_error($record['message']);
+            newrelic_notice_error($record->message);
         }
 
-        if (isset($record['formatted']['context']) && is_array($record['formatted']['context'])) {
-            foreach ($record['formatted']['context'] as $key => $parameter) {
+        if (isset($record->formatted['context']) && is_array($record->formatted['context'])) {
+            foreach ($record->formatted['context'] as $key => $parameter) {
                 if (is_array($parameter) && $this->explodeArrays) {
                     foreach ($parameter as $paramKey => $paramValue) {
                         $this->setNewRelicParameter('context_' . $key . '_' . $paramKey, $paramValue);
@@ -108,8 +108,8 @@ class NewRelicHandler extends AbstractProcessingHandler
             }
         }
 
-        if (isset($record['formatted']['extra']) && is_array($record['formatted']['extra'])) {
-            foreach ($record['formatted']['extra'] as $key => $parameter) {
+        if (isset($record->formatted['extra']) && is_array($record->formatted['extra'])) {
+            foreach ($record->formatted['extra'] as $key => $parameter) {
                 if (is_array($parameter) && $this->explodeArrays) {
                     foreach ($parameter as $paramKey => $paramValue) {
                         $this->setNewRelicParameter('extra_' . $key . '_' . $paramKey, $paramValue);

+ 2 - 2
src/Monolog/Handler/NullHandler.php

@@ -48,7 +48,7 @@ class NullHandler extends Handler
      */
     public function isHandling(LogRecord $record): bool
     {
-        return $record['level'] >= $this->level;
+        return $record->level >= $this->level;
     }
 
     /**
@@ -56,6 +56,6 @@ class NullHandler extends Handler
      */
     public function handle(LogRecord $record): bool
     {
-        return $record['level'] >= $this->level;
+        return $record->level >= $this->level;
     }
 }

+ 2 - 2
src/Monolog/Handler/OverflowHandler.php

@@ -90,11 +90,11 @@ class OverflowHandler extends AbstractHandler implements FormattableHandlerInter
      */
     public function handle(LogRecord $record): bool
     {
-        if ($record['level'] < $this->level) {
+        if ($record->level < $this->level) {
             return false;
         }
 
-        $level = $record['level'];
+        $level = $record->level;
 
         if (!isset($this->thresholdMap[$level])) {
             $this->thresholdMap[$level] = 0;

+ 5 - 16
src/Monolog/Handler/PHPConsoleHandler.php

@@ -38,8 +38,6 @@ use Monolog\LogRecord;
  *      PC::debug($_SERVER); // PHP Console debugger for any type of vars
  *
  * @author Sergey Barbushin https://www.linkedin.com/in/barbushin
- *
- * @phpstan-import-type Record from \Monolog\Logger
  */
 class PHPConsoleHandler extends AbstractProcessingHandler
 {
@@ -182,46 +180,37 @@ class PHPConsoleHandler extends AbstractProcessingHandler
      */
     protected function write(LogRecord $record): void
     {
-        if ($record['level'] < Logger::NOTICE) {
+        if ($record->level < Logger::NOTICE) {
             $this->handleDebugRecord($record);
-        } elseif (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Throwable) {
+        } elseif (isset($record->context['exception']) && $record->context['exception'] instanceof \Throwable) {
             $this->handleExceptionRecord($record);
         } else {
             $this->handleErrorRecord($record);
         }
     }
 
-    /**
-     * @phpstan-param Record $record
-     */
     private function handleDebugRecord(LogRecord $record): void
     {
         [$tags, $filteredContext] = $this->getRecordTags($record);
-        $message = $record['message'];
+        $message = $record->message;
         if ($filteredContext) {
             $message .= ' ' . Utils::jsonEncode($this->connector->getDumper()->dump(array_filter($filteredContext)), null, true);
         }
         $this->connector->getDebugDispatcher()->dispatchDebug($message, $tags, $this->options['classesPartialsTraceIgnore']);
     }
 
-    /**
-     * @phpstan-param Record $record
-     */
     private function handleExceptionRecord(LogRecord $record): void
     {
-        $this->connector->getErrorsDispatcher()->dispatchException($record['context']['exception']);
+        $this->connector->getErrorsDispatcher()->dispatchException($record->context['exception']);
     }
 
-    /**
-     * @phpstan-param Record $record
-     */
     private function handleErrorRecord(LogRecord $record): void
     {
         $context = $record->context;
 
         $this->connector->getErrorsDispatcher()->dispatchError(
             $context['code'] ?? null,
-            $context['message'] ?? $record['message'],
+            $context['message'] ?? $record->message,
             $context['file'] ?? null,
             $context['line'] ?? null,
             $this->options['classesPartialsTraceIgnore']

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

@@ -88,7 +88,7 @@ class ProcessHandler extends AbstractProcessingHandler
     {
         $this->ensureProcessIsStarted();
 
-        $this->writeProcessInput($record['formatted']);
+        $this->writeProcessInput($record->formatted);
 
         $errors = $this->readProcessErrors();
         if (empty($errors) === false) {

+ 3 - 4
src/Monolog/Handler/ProcessableHandlerInterface.php

@@ -12,20 +12,19 @@
 namespace Monolog\Handler;
 
 use Monolog\Processor\ProcessorInterface;
+use Monolog\LogRecord;
 
 /**
  * Interface to describe loggers that have processors
  *
  * @author Jordi Boggiano <j.boggiano@seld.be>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  */
 interface ProcessableHandlerInterface
 {
     /**
      * Adds a processor in the stack.
      *
-     * @psalm-param ProcessorInterface|callable(Record): Record $callback
+     * @phpstan-param ProcessorInterface|(callable(LogRecord): LogRecord) $callback
      *
      * @param  ProcessorInterface|callable $callback
      * @return HandlerInterface            self
@@ -35,7 +34,7 @@ interface ProcessableHandlerInterface
     /**
      * Removes the processor on top of the stack and returns it.
      *
-     * @psalm-return ProcessorInterface|callable(Record): Record $callback
+     * @phpstan-return ProcessorInterface|(callable(LogRecord): LogRecord) $callback
      *
      * @throws \LogicException             In case the processor stack is empty
      * @return callable|ProcessorInterface

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

@@ -24,7 +24,7 @@ trait ProcessableHandlerTrait
 {
     /**
      * @var callable[]
-     * @phpstan-var array<array<(callable(LogRecord): LogRecord)|ProcessorInterface>>
+     * @phpstan-var array<(callable(LogRecord): LogRecord)|ProcessorInterface>
      */
     protected $processors = [];
 

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

@@ -60,9 +60,9 @@ class PsrHandler extends AbstractHandler implements FormattableHandlerInterface
 
         if ($this->formatter) {
             $formatted = $this->formatter->format($record);
-            $this->logger->log(strtolower($record['level_name']), (string) $formatted, $record['context']);
+            $this->logger->log(strtolower($record->levelName), (string) $formatted, $record->context);
         } else {
-            $this->logger->log(strtolower($record['level_name']), $record['message'], $record['context']);
+            $this->logger->log(strtolower($record->levelName), $record->message, $record->context);
         }
 
         return false === $this->bubble;

+ 6 - 10
src/Monolog/Handler/PushoverHandler.php

@@ -22,7 +22,6 @@ use Monolog\LogRecord;
  * @author Sebastian Göttschkes <sebastian.goettschkes@googlemail.com>
  * @see    https://www.pushover.net/api
  *
- * @phpstan-import-type FormattedRecord from AbstractProcessingHandler
  * @phpstan-import-type Level from \Monolog\Logger
  * @phpstan-import-type LevelName from \Monolog\Logger
  */
@@ -144,18 +143,15 @@ class PushoverHandler extends SocketHandler
         return $this->buildHeader($content) . $content;
     }
 
-    /**
-     * @phpstan-param FormattedRecord $record
-     */
     private function buildContent(LogRecord $record): string
     {
         // Pushover has a limit of 512 characters on title and message combined.
         $maxMessageLength = 512 - strlen($this->title);
 
-        $message = ($this->useFormattedMessage) ? $record['formatted'] : $record['message'];
+        $message = ($this->useFormattedMessage) ? $record->formatted : $record->message;
         $message = Utils::substr($message, 0, $maxMessageLength);
 
-        $timestamp = $record['datetime']->getTimestamp();
+        $timestamp = $record->datetime->getTimestamp();
 
         $dataArray = [
             'token' => $this->token,
@@ -165,17 +161,17 @@ class PushoverHandler extends SocketHandler
             'timestamp' => $timestamp,
         ];
 
-        if (isset($record['level']) && $record['level'] >= $this->emergencyLevel) {
+        if (isset($record->level) && $record->level >= $this->emergencyLevel) {
             $dataArray['priority'] = 2;
             $dataArray['retry'] = $this->retry;
             $dataArray['expire'] = $this->expire;
-        } elseif (isset($record['level']) && $record['level'] >= $this->highPriorityLevel) {
+        } elseif (isset($record->level) && $record->level >= $this->highPriorityLevel) {
             $dataArray['priority'] = 1;
         }
 
         // First determine the available parameters
-        $context = array_intersect_key($record['context'], $this->parameterNames);
-        $extra = array_intersect_key($record['extra'], $this->parameterNames);
+        $context = array_intersect_key($record->context, $this->parameterNames);
+        $extra = array_intersect_key($record->extra, $this->parameterNames);
 
         // Least important info should be merged with subsequent info
         $dataArray = array_merge($extra, $context, $dataArray);

+ 5 - 9
src/Monolog/Handler/RedisHandler.php

@@ -26,12 +26,10 @@ use Monolog\LogRecord;
  *   $log->pushHandler($redis);
  *
  * @author Thomas Tourlourat <thomas@tourlourat.com>
- *
- * @phpstan-import-type FormattedRecord from AbstractProcessingHandler
  */
 class RedisHandler extends AbstractProcessingHandler
 {
-    /** @var \Predis\Client|\Redis */
+    /** @var \Predis\Client<\Predis\Client>|\Redis */
     private $redisClient;
     /** @var string */
     private $redisKey;
@@ -39,7 +37,7 @@ class RedisHandler extends AbstractProcessingHandler
     protected $capSize;
 
     /**
-     * @param \Predis\Client|\Redis $redis   The redis instance
+     * @param \Predis\Client<\Predis\Client>|\Redis $redis   The redis instance
      * @param string                $key     The key name to push records to
      * @param int                   $capSize Number of entries to limit list size to, 0 = unlimited
      */
@@ -64,29 +62,27 @@ class RedisHandler extends AbstractProcessingHandler
         if ($this->capSize) {
             $this->writeCapped($record);
         } else {
-            $this->redisClient->rpush($this->redisKey, $record["formatted"]);
+            $this->redisClient->rpush($this->redisKey, $record->formatted);
         }
     }
 
     /**
      * Write and cap the collection
      * Writes the record to the redis list and caps its
-     *
-     * @phpstan-param FormattedRecord $record
      */
     protected function writeCapped(LogRecord $record): void
     {
         if ($this->redisClient instanceof \Redis) {
             $mode = defined('\Redis::MULTI') ? \Redis::MULTI : 1;
             $this->redisClient->multi($mode)
-                ->rpush($this->redisKey, $record["formatted"])
+                ->rpush($this->redisKey, $record->formatted)
                 ->ltrim($this->redisKey, -$this->capSize, -1)
                 ->exec();
         } else {
             $redisKey = $this->redisKey;
             $capSize = $this->capSize;
             $this->redisClient->transaction(function ($tx) use ($record, $redisKey, $capSize) {
-                $tx->rpush($redisKey, $record["formatted"]);
+                $tx->rpush($redisKey, $record->formatted);
                 $tx->ltrim($redisKey, -$capSize, -1);
             });
         }

+ 3 - 3
src/Monolog/Handler/RedisPubSubHandler.php

@@ -29,13 +29,13 @@ use Monolog\LogRecord;
  */
 class RedisPubSubHandler extends AbstractProcessingHandler
 {
-    /** @var \Predis\Client|\Redis */
+    /** @var \Predis\Client<\Predis\Client>|\Redis */
     private $redisClient;
     /** @var string */
     private $channelKey;
 
     /**
-     * @param \Predis\Client|\Redis $redis The redis instance
+     * @param \Predis\Client<\Predis\Client>|\Redis $redis The redis instance
      * @param string                $key   The channel key to publish records to
      */
     public function __construct($redis, string $key, $level = Logger::DEBUG, bool $bubble = true)
@@ -55,7 +55,7 @@ class RedisPubSubHandler extends AbstractProcessingHandler
      */
     protected function write(LogRecord $record): void
     {
-        $this->redisClient->publish($this->channelKey, $record["formatted"]);
+        $this->redisClient->publish($this->channelKey, $record->formatted);
     }
 
     /**

+ 7 - 7
src/Monolog/Handler/RollbarHandler.php

@@ -82,12 +82,12 @@ class RollbarHandler extends AbstractProcessingHandler
             $this->initialized = true;
         }
 
-        $context = $record['context'];
-        $context = array_merge($context, $record['extra'], [
-            'level' => $this->levelMap[$record['level']],
-            'monolog_level' => $record['level_name'],
-            'channel' => $record['channel'],
-            'datetime' => $record['datetime']->format('U'),
+        $context = $record->context;
+        $context = array_merge($context, $record->extra, [
+            'level' => $this->levelMap[$record->level],
+            'monolog_level' => $record->levelName,
+            'channel' => $record->channel,
+            'datetime' => $record->datetime->format('U'),
         ]);
 
         if (isset($context['exception']) && $context['exception'] instanceof Throwable) {
@@ -95,7 +95,7 @@ class RollbarHandler extends AbstractProcessingHandler
             unset($context['exception']);
             $toLog = $exception;
         } else {
-            $toLog = $record['message'];
+            $toLog = $record->message;
         }
 
         // @phpstan-ignore-next-line

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

@@ -118,7 +118,7 @@ class RotatingFileHandler extends StreamHandler
             $this->mustRotate = null === $this->url || !file_exists($this->url);
         }
 
-        if ($this->nextRotation <= $record['datetime']) {
+        if ($this->nextRotation <= $record->datetime) {
             $this->mustRotate = true;
             $this->close();
         }

+ 2 - 7
src/Monolog/Handler/SamplingHandler.php

@@ -27,8 +27,6 @@ use Monolog\LogRecord;
  *
  * @author Bryan Davis <bd808@wikimedia.org>
  * @author Kunal Mehta <legoktm@gmail.com>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  * @phpstan-import-type Level from \Monolog\Logger
  */
 class SamplingHandler extends AbstractHandler implements ProcessableHandlerInterface, FormattableHandlerInterface
@@ -37,7 +35,7 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
 
     /**
      * @var HandlerInterface|callable
-     * @phpstan-var HandlerInterface|callable(Record|array{level: Level}|null, HandlerInterface): HandlerInterface
+     * @phpstan-var (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface
      */
     protected $handler;
 
@@ -47,7 +45,7 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
     protected $factor;
 
     /**
-     * @psalm-param HandlerInterface|callable(Record|array{level: Level}|null, HandlerInterface): HandlerInterface $handler
+     * @phpstan-param (callable(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler
      *
      * @param callable|HandlerInterface $handler Handler or factory callable($record|null, $samplingHandler).
      * @param int                       $factor  Sample factor (e.g. 10 means every ~10th record is sampled)
@@ -72,7 +70,6 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
     {
         if ($this->isHandling($record) && mt_rand(1, $this->factor) === 1) {
             if ($this->processors) {
-                /** @var Record $record */
                 $record = $this->processRecord($record);
             }
 
@@ -87,8 +84,6 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
      *
      * If the handler was provided as a factory callable, this will trigger the handler's instantiation.
      *
-     * @phpstan-param Record|array{level: Level}|null $record
-     *
      * @return HandlerInterface
      */
     public function getHandler(LogRecord $record = null)

+ 15 - 22
src/Monolog/Handler/Slack/SlackRecord.php

@@ -24,9 +24,6 @@ use Monolog\LogRecord;
  * @author Haralan Dobrev <hkdobrev@gmail.com>
  * @see    https://api.slack.com/incoming-webhooks
  * @see    https://api.slack.com/docs/message-attachments
- *
- * @phpstan-import-type FormattedRecord from \Monolog\Handler\AbstractProcessingHandler
- * @phpstan-import-type Record from \Monolog\Logger
  */
 class SlackRecord
 {
@@ -122,7 +119,6 @@ class SlackRecord
      * Returns required data in format that Slack
      * is expecting.
      *
-     * @phpstan-param FormattedRecord $record
      * @phpstan-return mixed[]
      */
     public function getSlackData(LogRecord $record): array
@@ -138,49 +134,48 @@ class SlackRecord
         }
 
         if ($this->formatter && !$this->useAttachment) {
-            /** @phpstan-ignore-next-line */
             $message = $this->formatter->format($record);
         } else {
             $message = $record->message;
         }
 
-        $record = $this->removeExcludedFields($record);
+        $recordData = $this->removeExcludedFields($record);
 
         if ($this->useAttachment) {
             $attachment = array(
-                'fallback'    => $message,
-                'text'        => $message,
-                'color'       => $this->getAttachmentColor($record['level']),
-                'fields'      => array(),
-                'mrkdwn_in'   => array('fields'),
-                'ts'          => $record['datetime']->getTimestamp(),
+                'fallback'  => $message,
+                'text'      => $message,
+                'color'     => $this->getAttachmentColor($recordData['level']),
+                'fields'    => array(),
+                'mrkdwn_in' => array('fields'),
+                'ts'        => $recordData['datetime']->getTimestamp(),
                 'footer'      => $this->username,
                 'footer_icon' => $this->userIcon,
             );
 
             if ($this->useShortAttachment) {
-                $attachment['title'] = $record['level_name'];
+                $attachment['title'] = $recordData['level_name'];
             } else {
                 $attachment['title'] = 'Message';
-                $attachment['fields'][] = $this->generateAttachmentField('Level', $record['level_name']);
+                $attachment['fields'][] = $this->generateAttachmentField('Level', $recordData['level_name']);
             }
 
             if ($this->includeContextAndExtra) {
                 foreach (array('extra', 'context') as $key) {
-                    if (empty($record[$key])) {
+                    if (empty($recordData[$key])) {
                         continue;
                     }
 
                     if ($this->useShortAttachment) {
                         $attachment['fields'][] = $this->generateAttachmentField(
                             (string) $key,
-                            $record[$key]
+                            $recordData[$key]
                         );
                     } else {
                         // Add all extra fields as individual fields in attachment
                         $attachment['fields'] = array_merge(
                             $attachment['fields'],
-                            $this->generateAttachmentFields($record[$key])
+                            $this->generateAttachmentFields($recordData[$key])
                         );
                     }
                 }
@@ -360,16 +355,14 @@ class SlackRecord
     /**
      * Get a copy of record with fields excluded according to $this->excludeFields
      *
-     * @phpstan-param FormattedRecord $record
-     *
      * @return mixed[]
      */
     private function removeExcludedFields(LogRecord $record): array
     {
-        $record = $record->toArray();
+        $recordData = $record->toArray();
         foreach ($this->excludeFields as $field) {
             $keys = explode('.', $field);
-            $node = &$record;
+            $node = &$recordData;
             $lastKey = end($keys);
             foreach ($keys as $key) {
                 if (!isset($node[$key])) {
@@ -383,6 +376,6 @@ class SlackRecord
             }
         }
 
-        return $record;
+        return $recordData;
     }
 }

+ 0 - 5
src/Monolog/Handler/SlackHandler.php

@@ -22,8 +22,6 @@ use Monolog\LogRecord;
  *
  * @author Greg Kedzierski <greg@gregkedzierski.com>
  * @see    https://api.slack.com/
- *
- * @phpstan-import-type FormattedRecord from AbstractProcessingHandler
  */
 class SlackHandler extends SocketHandler
 {
@@ -117,8 +115,6 @@ class SlackHandler extends SocketHandler
 
     /**
      * Builds the body of API call
-     *
-     * @phpstan-param FormattedRecord $record
      */
     private function buildContent(LogRecord $record): string
     {
@@ -128,7 +124,6 @@ class SlackHandler extends SocketHandler
     }
 
     /**
-     * @phpstan-param FormattedRecord $record
      * @return string[]
      */
     protected function prepareContentData(LogRecord $record): array

+ 1 - 7
src/Monolog/Handler/SocketHandler.php

@@ -19,9 +19,6 @@ use Monolog\LogRecord;
  *
  * @author Pablo de Leon Belloc <pablolb@gmail.com>
  * @see    http://php.net/manual/en/function.fsockopen.php
- *
- * @phpstan-import-type Record from \Monolog\Logger
- * @phpstan-import-type FormattedRecord from AbstractProcessingHandler
  */
 class SocketHandler extends AbstractProcessingHandler
 {
@@ -343,12 +340,9 @@ class SocketHandler extends AbstractProcessingHandler
         $this->connect();
     }
 
-    /**
-     * @phpstan-param FormattedRecord $record
-     */
     protected function generateDataStream(LogRecord $record): string
     {
-        return (string) $record['formatted'];
+        return (string) $record->formatted;
     }
 
     /**

+ 2 - 2
src/Monolog/Handler/SqsHandler.php

@@ -46,11 +46,11 @@ class SqsHandler extends AbstractProcessingHandler
      */
     protected function write(LogRecord $record): void
     {
-        if (!isset($record['formatted']) || 'string' !== gettype($record['formatted'])) {
+        if (!isset($record->formatted) || 'string' !== gettype($record->formatted)) {
             throw new \InvalidArgumentException('SqsHandler accepts only formatted records as a string' . Utils::getRecordMessageForException($record));
         }
 
-        $messageBody = $record['formatted'];
+        $messageBody = $record->formatted;
         if (strlen($messageBody) >= static::MAX_MESSAGE_SIZE) {
             $messageBody = Utils::substr($messageBody, 0, static::HEAD_MESSAGE_SIZE);
         }

+ 1 - 6
src/Monolog/Handler/StreamHandler.php

@@ -21,8 +21,6 @@ use Monolog\LogRecord;
  * Can be used to store into php://stderr, remote and local files, etc.
  *
  * @author Jordi Boggiano <j.boggiano@seld.be>
- *
- * @phpstan-import-type FormattedRecord from AbstractProcessingHandler
  */
 class StreamHandler extends AbstractProcessingHandler
 {
@@ -170,13 +168,10 @@ class StreamHandler extends AbstractProcessingHandler
     /**
      * Write to stream
      * @param resource $stream
-     * @param array    $record
-     *
-     * @phpstan-param FormattedRecord $record
      */
     protected function streamWrite($stream, LogRecord $record): void
     {
-        fwrite($stream, (string) $record['formatted']);
+        fwrite($stream, (string) $record->formatted);
     }
 
     private function customErrorHandler(int $code, string $msg): bool

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

@@ -64,6 +64,6 @@ class SyslogHandler extends AbstractSyslogHandler
         if (!openlog($this->ident, $this->logopts, $this->facility)) {
             throw new \LogicException('Can\'t open syslog for ident "'.$this->ident.'" and facility "'.$this->facility.'"' . Utils::getRecordMessageForException($record));
         }
-        syslog($this->logLevels[$record['level']], (string) $record['formatted']);
+        syslog($this->logLevels[$record->level], (string) $record->formatted);
     }
 }

+ 2 - 2
src/Monolog/Handler/SyslogUdpHandler.php

@@ -70,9 +70,9 @@ class SyslogUdpHandler extends AbstractSyslogHandler
 
     protected function write(LogRecord $record): void
     {
-        $lines = $this->splitMessageIntoLines($record['formatted']);
+        $lines = $this->splitMessageIntoLines($record->formatted);
 
-        $header = $this->makeCommonSyslogHeader($this->logLevels[$record['level']], $record['datetime']);
+        $header = $this->makeCommonSyslogHeader($this->logLevels[$record->level], $record->datetime);
 
         foreach ($lines as $line) {
             $this->socket->write($line, $header);

+ 1 - 5
src/Monolog/Handler/TelegramBotHandler.php

@@ -29,8 +29,6 @@ use Monolog\LogRecord;
  * @link https://core.telegram.org/bots/api
  *
  * @author Mazur Alexandr <alexandrmazur96@gmail.com>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  */
 class TelegramBotHandler extends AbstractProcessingHandler
 {
@@ -186,7 +184,6 @@ class TelegramBotHandler extends AbstractProcessingHandler
      */
     public function handleBatch(array $records): void
     {
-        /** @var Record[] $messages */
         $messages = [];
 
         foreach ($records as $record) {
@@ -195,7 +192,6 @@ class TelegramBotHandler extends AbstractProcessingHandler
             }
 
             if ($this->processors) {
-                /** @var Record $record */
                 $record = $this->processRecord($record);
             }
 
@@ -212,7 +208,7 @@ class TelegramBotHandler extends AbstractProcessingHandler
      */
     protected function write(LogRecord $record): void
     {
-        $this->send($record['formatted']);
+        $this->send($record->formatted);
     }
 
     /**

+ 11 - 15
src/Monolog/Handler/TestHandler.php

@@ -126,23 +126,23 @@ class TestHandler extends AbstractProcessingHandler
     }
 
     /**
-     * @param string|array $record Either a message string or an array containing message and optionally context keys that will be checked against all records
+     * @param string|array $recordAssertions Either a message string or an array containing message and optionally context keys that will be checked against all records
      * @param string|int   $level  Logging level value or name
      *
-     * @phpstan-param array{message: string, context?: mixed[]}|string $record
+     * @phpstan-param array{message: string, context?: mixed[]}|string $recordAssertions
      * @phpstan-param Level|LevelName|LogLevel::*                      $level
      */
-    public function hasRecord(string|array $record, $level): bool
+    public function hasRecord(string|array $recordAssertions, $level): bool
     {
-        if (is_string($record)) {
-            $record = ['message' => $record];
+        if (is_string($recordAssertions)) {
+            $recordAssertions = ['message' => $recordAssertions];
         }
 
-        return $this->hasRecordThatPasses(function (LogRecord $rec) use ($record) {
-            if ($rec->message !== $record['message']) {
+        return $this->hasRecordThatPasses(function (LogRecord $rec) use ($recordAssertions) {
+            if ($rec->message !== $recordAssertions['message']) {
                 return false;
             }
-            if (isset($record['context']) && $rec->context !== $record['context']) {
+            if (isset($recordAssertions['context']) && $rec->context !== $recordAssertions['context']) {
                 return false;
             }
 
@@ -157,9 +157,7 @@ class TestHandler extends AbstractProcessingHandler
      */
     public function hasRecordThatContains(string $message, $level): bool
     {
-        return $this->hasRecordThatPasses(function ($rec) use ($message) {
-            return strpos($rec['message'], $message) !== false;
-        }, $level);
+        return $this->hasRecordThatPasses(fn (LogRecord $rec) => str_contains($rec->message, $message), $level);
     }
 
     /**
@@ -169,16 +167,14 @@ class TestHandler extends AbstractProcessingHandler
      */
     public function hasRecordThatMatches(string $regex, $level): bool
     {
-        return $this->hasRecordThatPasses(function (LogRecord $rec) use ($regex): bool {
-            return preg_match($regex, $rec->message) > 0;
-        }, $level);
+        return $this->hasRecordThatPasses(fn (LogRecord $rec) => preg_match($regex, $rec->message) > 0, $level);
     }
 
     /**
      * @param  string|int $level Logging level value or name
      * @return bool
      *
-     * @psalm-param callable(LogRecord, int): mixed $predicate
+     * @phpstan-param callable(LogRecord, int): mixed $predicate
      * @phpstan-param Level|LevelName|LogLevel::* $level
      */
     public function hasRecordThatPasses(callable $predicate, $level)

+ 3 - 6
src/Monolog/Handler/WhatFailureGroupHandler.php

@@ -12,14 +12,13 @@
 namespace Monolog\Handler;
 
 use Monolog\LogRecord;
+use Throwable;
 
 /**
  * Forwards records to multiple handlers suppressing failures of each handler
  * and continuing through to give every handler a chance to succeed.
  *
  * @author Craig D'Amelio <craig@damelio.ca>
- *
- * @phpstan-import-type Record from \Monolog\Logger
  */
 class WhatFailureGroupHandler extends GroupHandler
 {
@@ -29,14 +28,13 @@ class WhatFailureGroupHandler extends GroupHandler
     public function handle(LogRecord $record): bool
     {
         if ($this->processors) {
-            /** @var Record $record */
             $record = $this->processRecord($record);
         }
 
         foreach ($this->handlers as $handler) {
             try {
                 $handler->handle($record);
-            } catch (\Throwable $e) {
+            } catch (Throwable) {
                 // What failure?
             }
         }
@@ -54,14 +52,13 @@ class WhatFailureGroupHandler extends GroupHandler
             foreach ($records as $record) {
                 $processed[] = $this->processRecord($record);
             }
-            /** @var Record[] $records */
             $records = $processed;
         }
 
         foreach ($this->handlers as $handler) {
             try {
                 $handler->handleBatch($records);
-            } catch (\Throwable $e) {
+            } catch (Throwable) {
                 // What failure?
             }
         }

+ 5 - 9
src/Monolog/Handler/ZendMonitorHandler.php

@@ -21,8 +21,6 @@ use Monolog\LogRecord;
  *
  * @author  Christian Bergau <cbergau86@gmail.com>
  * @author  Jason Davis <happydude@jasondavis.net>
- *
- * @phpstan-import-type FormattedRecord from AbstractProcessingHandler
  */
 class ZendMonitorHandler extends AbstractProcessingHandler
 {
@@ -63,10 +61,10 @@ class ZendMonitorHandler extends AbstractProcessingHandler
     protected function write(LogRecord $record): void
     {
         $this->writeZendMonitorCustomEvent(
-            Logger::getLevelName($record['level']),
-            $record['message'],
-            $record['formatted'],
-            $this->levelMap[$record['level']]
+            Logger::getLevelName($record->level),
+            $record->message,
+            $record->formatted,
+            $this->levelMap[$record->level]
         );
     }
 
@@ -74,10 +72,8 @@ class ZendMonitorHandler extends AbstractProcessingHandler
      * Write to Zend Monitor Events
      * @param string $type      Text displayed in "Class Name (custom)" field
      * @param string $message   Text displayed in "Error String"
-     * @param array  $formatted Displayed in Custom Variables tab
+     * @param array<mixed> $formatted Displayed in Custom Variables tab
      * @param int    $severity  Set the event severity level (-1,0,1)
-     *
-     * @phpstan-param FormattedRecord $formatted
      */
     protected function writeZendMonitorCustomEvent(string $type, string $message, array $formatted, int $severity): void
     {

+ 2 - 2
src/Monolog/Processor/GitProcessor.php

@@ -47,11 +47,11 @@ class GitProcessor implements ProcessorInterface
     public function __invoke(LogRecord $record): LogRecord
     {
         // return if the level is not high enough
-        if ($record['level'] < $this->level) {
+        if ($record->level < $this->level) {
             return $record;
         }
 
-        $record['extra']['git'] = self::getGitInfo();
+        $record->extra['git'] = self::getGitInfo();
 
         return $record;
     }

+ 1 - 1
src/Monolog/Processor/HostnameProcessor.php

@@ -31,7 +31,7 @@ class HostnameProcessor implements ProcessorInterface
      */
     public function __invoke(LogRecord $record): LogRecord
     {
-        $record['extra']['hostname'] = self::$host;
+        $record->extra['hostname'] = self::$host;
 
         return $record;
     }

+ 13 - 13
src/Monolog/Processor/IntrospectionProcessor.php

@@ -31,14 +31,14 @@ use Monolog\LogRecord;
  */
 class IntrospectionProcessor implements ProcessorInterface
 {
-    /** @var int */
-    private $level;
-    /** @var string[] */
-    private $skipClassesPartials;
-    /** @var int */
-    private $skipStackFramesCount;
+    private int $level;
+
     /** @var string[] */
-    private $skipFunctions = [
+    private array $skipClassesPartials;
+
+    private int $skipStackFramesCount;
+
+    private const SKIP_FUNCTIONS = [
         'call_user_func',
         'call_user_func_array',
     ];
@@ -62,7 +62,7 @@ class IntrospectionProcessor implements ProcessorInterface
     public function __invoke(LogRecord $record): LogRecord
     {
         // return if the level is not high enough
-        if ($record['level'] < $this->level) {
+        if ($record->level < $this->level) {
             return $record;
         }
 
@@ -84,7 +84,7 @@ class IntrospectionProcessor implements ProcessorInterface
                         continue 2;
                     }
                 }
-            } elseif (in_array($trace[$i]['function'], $this->skipFunctions)) {
+            } elseif (in_array($trace[$i]['function'], self::SKIP_FUNCTIONS)) {
                 $i++;
 
                 continue;
@@ -96,8 +96,8 @@ class IntrospectionProcessor implements ProcessorInterface
         $i += $this->skipStackFramesCount;
 
         // we should have the call source now
-        $record['extra'] = array_merge(
-            $record['extra'],
+        $record->extra = array_merge(
+            $record->extra,
             [
                 'file'      => isset($trace[$i - 1]['file']) ? $trace[$i - 1]['file'] : null,
                 'line'      => isset($trace[$i - 1]['line']) ? $trace[$i - 1]['line'] : null,
@@ -111,7 +111,7 @@ class IntrospectionProcessor implements ProcessorInterface
     }
 
     /**
-     * @param array[] $trace
+     * @param array<mixed> $trace
      */
     private function isTraceClassOrSkippedFunction(array $trace, int $index): bool
     {
@@ -119,6 +119,6 @@ class IntrospectionProcessor implements ProcessorInterface
             return false;
         }
 
-        return isset($trace[$index]['class']) || in_array($trace[$index]['function'], $this->skipFunctions);
+        return isset($trace[$index]['class']) || in_array($trace[$index]['function'], self::SKIP_FUNCTIONS);
     }
 }

+ 1 - 1
src/Monolog/Processor/MemoryPeakUsageProcessor.php

@@ -32,7 +32,7 @@ class MemoryPeakUsageProcessor extends MemoryProcessor
             $usage = $this->formatBytes($usage);
         }
 
-        $record['extra']['memory_peak_usage'] = $usage;
+        $record->extra['memory_peak_usage'] = $usage;
 
         return $record;
     }

+ 1 - 1
src/Monolog/Processor/MemoryUsageProcessor.php

@@ -32,7 +32,7 @@ class MemoryUsageProcessor extends MemoryProcessor
             $usage = $this->formatBytes($usage);
         }
 
-        $record['extra']['memory_usage'] = $usage;
+        $record->extra['memory_usage'] = $usage;
 
         return $record;
     }

+ 2 - 2
src/Monolog/Processor/MercurialProcessor.php

@@ -46,11 +46,11 @@ class MercurialProcessor implements ProcessorInterface
     public function __invoke(LogRecord $record): LogRecord
     {
         // return if the level is not high enough
-        if ($record['level'] < $this->level) {
+        if ($record->level < $this->level) {
             return $record;
         }
 
-        $record['extra']['hg'] = self::getMercurialInfo();
+        $record->extra['hg'] = self::getMercurialInfo();
 
         return $record;
     }

+ 1 - 1
src/Monolog/Processor/ProcessIdProcessor.php

@@ -25,7 +25,7 @@ class ProcessIdProcessor implements ProcessorInterface
      */
     public function __invoke(LogRecord $record): LogRecord
     {
-        $record['extra']['process_id'] = getmypid();
+        $record->extra['process_id'] = getmypid();
 
         return $record;
     }

+ 4 - 4
src/Monolog/Processor/PsrLogMessageProcessor.php

@@ -46,16 +46,16 @@ class PsrLogMessageProcessor implements ProcessorInterface
      */
     public function __invoke(LogRecord $record): LogRecord
     {
-        if (false === strpos($record['message'], '{')) {
+        if (false === strpos($record->message, '{')) {
             return $record;
         }
 
         $replacements = [];
-        $context = $record['context'];
+        $context = $record->context;
 
         foreach ($context as $key => $val) {
             $placeholder = '{' . $key . '}';
-            if (strpos($record['message'], $placeholder) === false) {
+            if (strpos($record->message, $placeholder) === false) {
                 continue;
             }
 
@@ -82,6 +82,6 @@ class PsrLogMessageProcessor implements ProcessorInterface
             }
         }
 
-        return $record->with(message: strtr($record['message'], $replacements), context: $context);
+        return $record->with(message: strtr($record->message, $replacements), context: $context);
     }
 }

+ 1 - 1
src/Monolog/Processor/UidProcessor.php

@@ -38,7 +38,7 @@ class UidProcessor implements ProcessorInterface, ResettableInterface
      */
     public function __invoke(LogRecord $record): LogRecord
     {
-        $record['extra']['uid'] = $this->uid;
+        $record->extra['uid'] = $this->uid;
 
         return $record;
     }

+ 1 - 1
src/Monolog/Processor/WebProcessor.php

@@ -86,7 +86,7 @@ class WebProcessor implements ProcessorInterface
             return $record;
         }
 
-        $record['extra'] = $this->appendExtraFields($record['extra']);
+        $record->extra = $this->appendExtraFields($record->extra);
 
         return $record;
     }

+ 2 - 1
src/Monolog/Test/TestCase.php

@@ -26,7 +26,8 @@ use Monolog\Formatter\FormatterInterface;
 class TestCase extends \PHPUnit\Framework\TestCase
 {
     /**
-     * @param mixed[] $context
+     * @param array<mixed> $context
+     * @param array<mixed> $extra
      *
      * @phpstan-param  Level $level
      */

+ 4 - 4
tests/Monolog/Formatter/JsonFormatterTest.php

@@ -43,7 +43,7 @@ class JsonFormatterTest extends TestCase
 
         $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false);
         $record = $this->getRecord();
-        $this->assertEquals('{"message":"test","context":{},"level":300,"level_name":"WARNING","channel":"test","datetime":"'.$record['datetime']->format('Y-m-d\TH:i:s.uP').'","extra":{}}', $formatter->format($record));
+        $this->assertEquals('{"message":"test","context":{},"level":300,"level_name":"WARNING","channel":"test","datetime":"'.$record->datetime->format('Y-m-d\TH:i:s.uP').'","extra":{}}', $formatter->format($record));
     }
 
     /**
@@ -66,7 +66,7 @@ class JsonFormatterTest extends TestCase
     "level": 300,
     "level_name": "WARNING",
     "channel": "test",
-    "datetime": "'.$record['datetime']->format('Y-m-d\TH:i:s.uP').'",
+    "datetime": "'.$record->datetime->format('Y-m-d\TH:i:s.uP').'",
     "extra": {}
 }',
             $formatter->format($record)
@@ -74,7 +74,7 @@ class JsonFormatterTest extends TestCase
 
         $formatter->setJsonPrettyPrint(false);
         $record = $this->getRecord();
-        $this->assertEquals('{"message":"test","context":{},"level":300,"level_name":"WARNING","channel":"test","datetime":"'.$record['datetime']->format('Y-m-d\TH:i:s.uP').'","extra":{}}', $formatter->format($record));
+        $this->assertEquals('{"message":"test","context":{},"level":300,"level_name":"WARNING","channel":"test","datetime":"'.$record->datetime->format('Y-m-d\TH:i:s.uP').'","extra":{}}', $formatter->format($record));
     }
 
     /**
@@ -187,7 +187,7 @@ class JsonFormatterTest extends TestCase
         $record = $this->getRecord(
             context: ['field_resource' => opendir(__DIR__)],
         );
-        $this->assertEquals('{"message":"test","context":{"field_resource":"[resource(stream)]"},"level":300,"level_name":"WARNING","channel":"test","datetime":"'.$record['datetime']->format('Y-m-d\TH:i:s.uP').'","extra":{}}', $formatter->format($record));
+        $this->assertEquals('{"message":"test","context":{"field_resource":"[resource(stream)]"},"level":300,"level_name":"WARNING","channel":"test","datetime":"'.$record->datetime->format('Y-m-d\TH:i:s.uP').'","extra":{}}', $formatter->format($record));
     }
 
     /**

+ 1 - 1
tests/Monolog/Formatter/LogglyFormatterTest.php

@@ -36,6 +36,6 @@ class LogglyFormatterTest extends TestCase
         $formatted_decoded = json_decode($formatter->format($record), true);
         $this->assertArrayNotHasKey("datetime", $formatted_decoded);
         $this->assertArrayHasKey("timestamp", $formatted_decoded);
-        $this->assertEquals($record["datetime"]->format('Y-m-d\TH:i:s.uO'), $formatted_decoded["timestamp"]);
+        $this->assertEquals($record->datetime->format('Y-m-d\TH:i:s.uO'), $formatted_decoded["timestamp"]);
     }
 }

+ 1 - 1
tests/Monolog/Handler/BufferHandlerTest.php

@@ -145,7 +145,7 @@ class BufferHandlerTest extends TestCase
         $test = new TestHandler();
         $handler = new BufferHandler($test);
         $handler->pushProcessor(function ($record) {
-            $record['extra']['foo'] = true;
+            $record->extra['foo'] = true;
 
             return $record;
         });

+ 2 - 2
tests/Monolog/Handler/DeduplicationHandlerTest.php

@@ -122,7 +122,7 @@ class DeduplicationHandlerTest extends TestCase
         // log is written as none of them are duplicate
         $handler->flush();
         $this->assertSame(
-            $record['datetime']->getTimestamp() . ":ERROR:test\n" .
+            $record->datetime->getTimestamp() . ":ERROR:test\n" .
             $record2['datetime']->getTimestamp() . ":CRITICAL:test\n" .
             $record3['datetime']->getTimestamp() . ":CRITICAL:test\n",
             file_get_contents(sys_get_temp_dir() . '/monolog_dedup.log')
@@ -144,7 +144,7 @@ class DeduplicationHandlerTest extends TestCase
         // log should now contain the new errors and the previous one that was recent enough
         $this->assertSame(
             $record3['datetime']->getTimestamp() . ":CRITICAL:test\n" .
-            $record['datetime']->getTimestamp() . ":ERROR:test\n" .
+            $record->datetime->getTimestamp() . ":ERROR:test\n" .
             $record2['datetime']->getTimestamp() . ":CRITICAL:test\n",
             file_get_contents(sys_get_temp_dir() . '/monolog_dedup.log')
         );

+ 1 - 1
tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php

@@ -38,7 +38,7 @@ class DoctrineCouchDBHandlerTest extends TestCase
             'level' => Logger::WARNING,
             'level_name' => 'WARNING',
             'channel' => 'test',
-            'datetime' => (string) $record['datetime'],
+            'datetime' => (string) $record->datetime,
             'extra' => [],
         ];
 

+ 3 - 3
tests/Monolog/Handler/FallbackGroupHandlerTest.php

@@ -98,7 +98,7 @@ class FallbackGroupHandlerTest extends TestCase
         $test = new TestHandler();
         $handler = new FallbackGroupHandler([$test]);
         $handler->pushProcessor(function ($record) {
-            $record['extra']['foo'] = true;
+            $record->extra['foo'] = true;
 
             return $record;
         });
@@ -118,12 +118,12 @@ class FallbackGroupHandlerTest extends TestCase
         $testHandlers = [$testHandlerOne, $testHandlerTwo];
         $handler = new FallbackGroupHandler($testHandlers);
         $handler->pushProcessor(function ($record) {
-            $record['extra']['foo'] = true;
+            $record->extra['foo'] = true;
 
             return $record;
         });
         $handler->pushProcessor(function ($record) {
-            $record['extra']['foo2'] = true;
+            $record->extra['foo2'] = true;
 
             return $record;
         });

+ 1 - 1
tests/Monolog/Handler/FilterHandlerTest.php

@@ -110,7 +110,7 @@ class FilterHandlerTest extends TestCase
         $handler = new FilterHandler($test, Logger::DEBUG, Logger::EMERGENCY);
         $handler->pushProcessor(
             function ($record) {
-                $record['extra']['foo'] = true;
+                $record->extra['foo'] = true;
 
                 return $record;
             }

+ 6 - 6
tests/Monolog/Handler/GelfHandlerTest.php

@@ -56,8 +56,8 @@ class GelfHandlerTest extends TestCase
         $expectedMessage
             ->setLevel(7)
             ->setFacility("test")
-            ->setShortMessage($record['message'])
-            ->setTimestamp($record['datetime'])
+            ->setShortMessage($record->message)
+            ->setTimestamp($record->datetime)
         ;
 
         $messagePublisher = $this->getMessagePublisher();
@@ -77,8 +77,8 @@ class GelfHandlerTest extends TestCase
         $expectedMessage
             ->setLevel(4)
             ->setFacility("test")
-            ->setShortMessage($record['message'])
-            ->setTimestamp($record['datetime'])
+            ->setShortMessage($record->message)
+            ->setTimestamp($record->datetime)
         ;
 
         $messagePublisher = $this->getMessagePublisher();
@@ -105,8 +105,8 @@ class GelfHandlerTest extends TestCase
             ->setLevel(4)
             ->setFacility("test")
             ->setHost("mysystem")
-            ->setShortMessage($record['message'])
-            ->setTimestamp($record['datetime'])
+            ->setShortMessage($record->message)
+            ->setTimestamp($record->datetime)
             ->setAdditional("EXTblarg", 'yep')
             ->setAdditional("CTXfrom", 'logger')
         ;

+ 3 - 3
tests/Monolog/Handler/GroupHandlerTest.php

@@ -78,7 +78,7 @@ class GroupHandlerTest extends TestCase
         $test = new TestHandler();
         $handler = new GroupHandler([$test]);
         $handler->pushProcessor(function ($record) {
-            $record['extra']['foo'] = true;
+            $record->extra['foo'] = true;
 
             return $record;
         });
@@ -96,12 +96,12 @@ class GroupHandlerTest extends TestCase
         $testHandlers = [new TestHandler(), new TestHandler()];
         $handler = new GroupHandler($testHandlers);
         $handler->pushProcessor(function ($record) {
-            $record['extra']['foo'] = true;
+            $record->extra['foo'] = true;
 
             return $record;
         });
         $handler->pushProcessor(function ($record) {
-            $record['extra']['foo2'] = true;
+            $record->extra['foo2'] = true;
 
             return $record;
         });

+ 1 - 1
tests/Monolog/Handler/MailHandlerTest.php

@@ -65,7 +65,7 @@ class MailHandlerTest extends TestCase
 
         $record = $this->getRecord();
         $records = [$record];
-        $records[0]['formatted'] = '['.$record['datetime'].'] test.WARNING: test [] []'."\n";
+        $records[0]['formatted'] = '['.$record->datetime.'] test.WARNING: test [] []'."\n";
 
         $handler->expects($this->once())
             ->method('send')

+ 1 - 1
tests/Monolog/Handler/MongoDBHandlerTest.php

@@ -44,7 +44,7 @@ class MongoDBHandlerTest extends TestCase
 
         $record = $this->getRecord();
         $expected = $record->toArray();
-        $expected['datetime'] = new \MongoDB\BSON\UTCDateTime((int) floor(((float) $record['datetime']->format('U.u')) * 1000));
+        $expected['datetime'] = new \MongoDB\BSON\UTCDateTime((int) floor(((float) $record->datetime->format('U.u')) * 1000));
 
         $collection->expects($this->once())
             ->method('insertOne')

+ 3 - 3
tests/Monolog/Handler/NewRelicHandlerTest.php

@@ -67,7 +67,7 @@ class NewRelicHandlerTest extends TestCase
     public function testThehandlerCanAddExtraParamsToTheNewRelicTrace()
     {
         $record = $this->getRecord(Logger::ERROR, 'log message');
-        $record['extra'] = ['c' => 'd'];
+        $record->extra = ['c' => 'd'];
 
         $handler = new StubNewRelicHandler();
         $handler->handle($record);
@@ -78,7 +78,7 @@ class NewRelicHandlerTest extends TestCase
     public function testThehandlerCanAddExplodedExtraParamsToTheNewRelicTrace()
     {
         $record = $this->getRecord(Logger::ERROR, 'log message');
-        $record['extra'] = ['c' => ['key1' => 'value1', 'key2' => 'value2']];
+        $record->extra = ['c' => ['key1' => 'value1', 'key2' => 'value2']];
 
         $handler = new StubNewRelicHandler(Logger::ERROR, true, self::$appname, true);
         $handler->handle($record);
@@ -92,7 +92,7 @@ class NewRelicHandlerTest extends TestCase
     public function testThehandlerCanAddExtraContextAndParamsToTheNewRelicTrace()
     {
         $record = $this->getRecord(Logger::ERROR, 'log message', ['a' => 'b']);
-        $record['extra'] = ['c' => 'd'];
+        $record->extra = ['c' => 'd'];
 
         $handler = new StubNewRelicHandler();
         $handler->handle($record);

+ 5 - 5
tests/Monolog/Handler/Slack/SlackRecordTest.php

@@ -168,7 +168,7 @@ class SlackRecordTest extends TestCase
             ->expects($this->any())
             ->method('format')
             ->will($this->returnCallback(function ($record) {
-                return $record['message'] . 'test';
+                return $record->message . 'test';
             }));
 
         $formatter2 = $this->createMock('Monolog\\Formatter\\FormatterInterface');
@@ -176,7 +176,7 @@ class SlackRecordTest extends TestCase
             ->expects($this->any())
             ->method('format')
             ->will($this->returnCallback(function ($record) {
-                return $record['message'] . 'test1';
+                return $record->message . 'test1';
             }));
 
         $message = 'Test message';
@@ -345,7 +345,7 @@ class SlackRecordTest extends TestCase
 
         $attachment = $data['attachments'][0];
         $this->assertArrayHasKey('ts', $attachment);
-        $this->assertSame($record['datetime']->getTimestamp(), $attachment['ts']);
+        $this->assertSame($record->datetime->getTimestamp(), $attachment['ts']);
     }
 
     public function testContextHasException()
@@ -361,9 +361,9 @@ class SlackRecordTest extends TestCase
         $record = $this->getRecord(
             Logger::WARNING,
             'test',
-            array('info' => array('library' => 'monolog', 'author' => 'Jordi'))
+            context: array('info' => array('library' => 'monolog', 'author' => 'Jordi')),
+            extra: array('tags' => array('web', 'cli')),
         );
-        $record['extra'] = array('tags' => array('web', 'cli'));
 
         $slackRecord = new SlackRecord(null, null, true, null, false, true, array('context.info.library', 'extra.tags.1'));
         $data = $slackRecord->getSlackData($record);

+ 1 - 1
tests/Monolog/Handler/SlackWebhookHandlerTest.php

@@ -50,7 +50,7 @@ class SlackWebhookHandlerTest extends TestCase
                     ),
                     'title' => 'Message',
                     'mrkdwn_in' => array('fields'),
-                    'ts' => $record['datetime']->getTimestamp(),
+                    'ts' => $record->datetime->getTimestamp(),
                     'footer' => null,
                     'footer_icon' => null,
                 ),

+ 4 - 4
tests/Monolog/Handler/WhatFailureGroupHandlerTest.php

@@ -78,7 +78,7 @@ class WhatFailureGroupHandlerTest extends TestCase
         $test = new TestHandler();
         $handler = new WhatFailureGroupHandler([$test]);
         $handler->pushProcessor(function ($record) {
-            $record['extra']['foo'] = true;
+            $record->extra['foo'] = true;
 
             return $record;
         });
@@ -96,12 +96,12 @@ class WhatFailureGroupHandlerTest extends TestCase
         $testHandlers = array(new TestHandler(), new TestHandler());
         $handler = new WhatFailureGroupHandler($testHandlers);
         $handler->pushProcessor(function ($record) {
-            $record['extra']['foo'] = true;
+            $record->extra['foo'] = true;
 
             return $record;
         });
         $handler->pushProcessor(function ($record) {
-            $record['extra']['foo2'] = true;
+            $record->extra['foo2'] = true;
 
             return $record;
         });
@@ -127,7 +127,7 @@ class WhatFailureGroupHandlerTest extends TestCase
         $exception = new ExceptionTestHandler();
         $handler = new WhatFailureGroupHandler([$exception, $test, $exception]);
         $handler->pushProcessor(function ($record) {
-            $record['extra']['foo'] = true;
+            $record->extra['foo'] = true;
 
             return $record;
         });

+ 4 - 4
tests/Monolog/Handler/ZendMonitorHandlerTest.php

@@ -32,7 +32,7 @@ class ZendMonitorHandlerTest extends TestCase
     {
         $record = $this->getRecord();
         $formatterResult = [
-            'message' => $record['message'],
+            'message' => $record->message,
         ];
 
         $zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler')
@@ -56,10 +56,10 @@ class ZendMonitorHandlerTest extends TestCase
         $zendMonitor->expects($this->once())
             ->method('writeZendMonitorCustomEvent')
             ->with(
-                Logger::getLevelName($record['level']),
-                $record['message'],
+                Logger::getLevelName($record->level),
+                $record->message,
                 $formatterResult,
-                $levelMap[$record['level']]
+                $levelMap[$record->level]
             );
 
         $zendMonitor->handle($record);

+ 12 - 12
tests/Monolog/LoggerTest.php

@@ -82,7 +82,7 @@ class LoggerTest extends TestCase
         $logger->pushHandler($handler);
         $logger->warning('test');
         list($record) = $handler->getRecords();
-        $this->assertEquals('foo', $record['channel']);
+        $this->assertEquals('foo', $record->channel);
     }
 
     /**
@@ -229,13 +229,13 @@ class LoggerTest extends TestCase
         $handler = new TestHandler;
         $logger->pushHandler($handler);
         $logger->pushProcessor(function ($record) {
-            $record['extra']['win'] = true;
+            $record->extra['win'] = true;
 
             return $record;
         });
         $logger->error('test');
         list($record) = $handler->getRecords();
-        $this->assertTrue($record['extra']['win']);
+        $this->assertTrue($record->extra['win']);
     }
 
     /**
@@ -478,7 +478,7 @@ class LoggerTest extends TestCase
         $logger->pushHandler($handler);
         $logger->{$method}('test');
         list($record) = $handler->getRecords();
-        $this->assertEquals($expectedLevel, $record['level']);
+        $this->assertEquals($expectedLevel, $record->level);
     }
 
     public function logMethodProvider()
@@ -508,7 +508,7 @@ class LoggerTest extends TestCase
         $logger->pushHandler($handler);
         $logger->info('test');
         list($record) = $handler->getRecords();
-        $this->assertEquals($tz, $record['datetime']->getTimezone());
+        $this->assertEquals($tz, $record->datetime->getTimezone());
     }
 
     public function setTimezoneProvider()
@@ -538,8 +538,8 @@ class LoggerTest extends TestCase
             $logger->info('test');
             list($record) = $handler->getRecords();
 
-            $this->assertEquals($tz, $record['datetime']->getTimezone());
-            $this->assertEquals($dt->format('Y/m/d H:i'), $record['datetime']->format('Y/m/d H:i'), 'Time should match timezone with microseconds set to: '.var_export($microseconds, true));
+            $this->assertEquals($tz, $record->datetime->getTimezone());
+            $this->assertEquals($dt->format('Y/m/d H:i'), $record->datetime->format('Y/m/d H:i'), 'Time should match timezone with microseconds set to: '.var_export($microseconds, true));
         }
     }
 
@@ -561,8 +561,8 @@ class LoggerTest extends TestCase
             $logger->info('test');
             list($record) = $handler->getRecords();
 
-            $this->assertEquals($tz, $record['datetime']->getTimezone());
-            $this->assertEquals($dt->format('Y/m/d H:i'), $record['datetime']->format('Y/m/d H:i'), 'Time should match timezone with microseconds set to: '.var_export($microseconds, true));
+            $this->assertEquals($tz, $record->datetime->getTimezone());
+            $this->assertEquals($dt->format('Y/m/d H:i'), $record->datetime->format('Y/m/d H:i'), 'Time should match timezone with microseconds set to: '.var_export($microseconds, true));
         }
     }
 
@@ -588,8 +588,8 @@ class LoggerTest extends TestCase
         $logger->pushHandler($handler);
         $logger->info('test');
         list($record) = $handler->getRecords();
-        $this->{$assert}('000000', $record['datetime']->format('u'));
-        $this->assertSame($record['datetime']->format($assertFormat), (string) $record['datetime']);
+        $this->{$assert}('000000', $record->datetime->format('u'));
+        $this->assertSame($record->datetime->format($assertFormat), (string) $record->datetime);
     }
 
     public function useMicrosecondTimestampsProvider()
@@ -648,7 +648,7 @@ class LoggerTest extends TestCase
         $logger->setExceptionHandler(function ($e, $record) use ($that) {
             $that->assertEquals($e->getMessage(), 'Some handler exception');
             $that->assertInstanceOf(LogRecord::class, $record);
-            $that->assertEquals($record['message'], 'test');
+            $that->assertEquals($record->message, 'test');
         });
         $handler = $this->getMockBuilder('Monolog\Handler\HandlerInterface')->getMock();
         $handler->expects($this->any())

+ 2 - 2
tests/Monolog/Processor/GitProcessorTest.php

@@ -23,7 +23,7 @@ class GitProcessorTest extends TestCase
         $processor = new GitProcessor();
         $record = $processor($this->getRecord());
 
-        $this->assertArrayHasKey('git', $record['extra']);
-        $this->assertTrue(!is_array($record['extra']['git']['branch']));
+        $this->assertArrayHasKey('git', $record->extra);
+        $this->assertTrue(!is_array($record->extra['git']['branch']));
     }
 }

+ 4 - 4
tests/Monolog/Processor/HostnameProcessorTest.php

@@ -22,9 +22,9 @@ class HostnameProcessorTest extends TestCase
     {
         $processor = new HostnameProcessor();
         $record = $processor($this->getRecord());
-        $this->assertArrayHasKey('hostname', $record['extra']);
-        $this->assertIsString($record['extra']['hostname']);
-        $this->assertNotEmpty($record['extra']['hostname']);
-        $this->assertEquals(gethostname(), $record['extra']['hostname']);
+        $this->assertArrayHasKey('hostname', $record->extra);
+        $this->assertIsString($record->extra['hostname']);
+        $this->assertNotEmpty($record->extra['hostname']);
+        $this->assertEquals(gethostname(), $record->extra['hostname']);
     }
 }

Vissa filer visades inte eftersom för många filer har ändrats