2
0
Эх сурвалжийг харах

Move to strict mode and fix tests

Jordi Boggiano 9 жил өмнө
parent
commit
21dde4dedb
100 өөрчлөгдсөн 149 нэмэгдсэн , 152 устгасан
  1. 1 1
      .php_cs
  2. 1 1
      composer.json
  3. 5 3
      src/Monolog/DateTimeImmutable.php
  4. 1 1
      src/Monolog/ErrorHandler.php
  5. 1 1
      src/Monolog/Formatter/ChromePHPFormatter.php
  6. 1 1
      src/Monolog/Formatter/ElasticaFormatter.php
  7. 1 1
      src/Monolog/Formatter/FlowdockFormatter.php
  8. 1 1
      src/Monolog/Formatter/FluentdFormatter.php
  9. 1 1
      src/Monolog/Formatter/FormatterInterface.php
  10. 7 2
      src/Monolog/Formatter/GelfMessageFormatter.php
  11. 3 2
      src/Monolog/Formatter/HtmlFormatter.php
  12. 1 1
      src/Monolog/Formatter/JsonFormatter.php
  13. 1 1
      src/Monolog/Formatter/LineFormatter.php
  14. 1 1
      src/Monolog/Formatter/LogglyFormatter.php
  15. 1 1
      src/Monolog/Formatter/LogstashFormatter.php
  16. 1 1
      src/Monolog/Formatter/MongoDBFormatter.php
  17. 15 8
      src/Monolog/Formatter/NormalizerFormatter.php
  18. 1 1
      src/Monolog/Formatter/ScalarFormatter.php
  19. 1 1
      src/Monolog/Formatter/WildfireFormatter.php
  20. 1 1
      src/Monolog/Handler/AbstractHandler.php
  21. 1 1
      src/Monolog/Handler/AbstractProcessingHandler.php
  22. 2 2
      src/Monolog/Handler/AbstractSyslogHandler.php
  23. 1 1
      src/Monolog/Handler/AmqpHandler.php
  24. 1 1
      src/Monolog/Handler/BrowserConsoleHandler.php
  25. 1 1
      src/Monolog/Handler/BufferHandler.php
  26. 1 1
      src/Monolog/Handler/ChromePHPHandler.php
  27. 2 2
      src/Monolog/Handler/CouchDBHandler.php
  28. 1 1
      src/Monolog/Handler/CubeHandler.php
  29. 1 1
      src/Monolog/Handler/Curl/Util.php
  30. 2 2
      src/Monolog/Handler/DeduplicationHandler.php
  31. 1 1
      src/Monolog/Handler/DoctrineCouchDBHandler.php
  32. 1 1
      src/Monolog/Handler/DynamoDbHandler.php
  33. 1 1
      src/Monolog/Handler/ElasticSearchHandler.php
  34. 1 1
      src/Monolog/Handler/ErrorLogHandler.php
  35. 1 1
      src/Monolog/Handler/FilterHandler.php
  36. 1 1
      src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php
  37. 1 1
      src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php
  38. 1 1
      src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php
  39. 1 1
      src/Monolog/Handler/FingersCrossedHandler.php
  40. 1 1
      src/Monolog/Handler/FirePHPHandler.php
  41. 1 1
      src/Monolog/Handler/FleepHookHandler.php
  42. 1 1
      src/Monolog/Handler/FlowdockHandler.php
  43. 1 1
      src/Monolog/Handler/FormattableHandlerInterface.php
  44. 1 1
      src/Monolog/Handler/FormattableHandlerTrait.php
  45. 1 1
      src/Monolog/Handler/GelfHandler.php
  46. 1 1
      src/Monolog/Handler/GroupHandler.php
  47. 1 1
      src/Monolog/Handler/Handler.php
  48. 1 1
      src/Monolog/Handler/HandlerInterface.php
  49. 1 1
      src/Monolog/Handler/HandlerWrapper.php
  50. 1 1
      src/Monolog/Handler/HipChatHandler.php
  51. 1 1
      src/Monolog/Handler/IFTTTHandler.php
  52. 1 1
      src/Monolog/Handler/LogEntriesHandler.php
  53. 1 1
      src/Monolog/Handler/LogglyHandler.php
  54. 2 2
      src/Monolog/Handler/MailHandler.php
  55. 1 1
      src/Monolog/Handler/MandrillHandler.php
  56. 1 1
      src/Monolog/Handler/MissingExtensionException.php
  57. 1 1
      src/Monolog/Handler/MongoDBHandler.php
  58. 2 2
      src/Monolog/Handler/NativeMailerHandler.php
  59. 1 1
      src/Monolog/Handler/NewRelicHandler.php
  60. 1 1
      src/Monolog/Handler/NullHandler.php
  61. 1 1
      src/Monolog/Handler/PHPConsoleHandler.php
  62. 1 1
      src/Monolog/Handler/ProcessHandler.php
  63. 1 1
      src/Monolog/Handler/ProcessableHandlerInterface.php
  64. 1 1
      src/Monolog/Handler/ProcessableHandlerTrait.php
  65. 1 1
      src/Monolog/Handler/PsrHandler.php
  66. 1 1
      src/Monolog/Handler/PushoverHandler.php
  67. 1 1
      src/Monolog/Handler/RavenHandler.php
  68. 1 1
      src/Monolog/Handler/RedisHandler.php
  69. 1 1
      src/Monolog/Handler/RollbarHandler.php
  70. 3 2
      src/Monolog/Handler/RotatingFileHandler.php
  71. 1 1
      src/Monolog/Handler/SamplingHandler.php
  72. 1 1
      src/Monolog/Handler/SendGridHandler.php
  73. 2 2
      src/Monolog/Handler/SlackHandler.php
  74. 1 1
      src/Monolog/Handler/SocketHandler.php
  75. 1 1
      src/Monolog/Handler/StreamHandler.php
  76. 8 7
      src/Monolog/Handler/SwiftMailerHandler.php
  77. 1 1
      src/Monolog/Handler/SyslogHandler.php
  78. 1 1
      src/Monolog/Handler/SyslogUdp/UdpSocket.php
  79. 1 1
      src/Monolog/Handler/SyslogUdpHandler.php
  80. 1 1
      src/Monolog/Handler/TestHandler.php
  81. 1 1
      src/Monolog/Handler/WhatFailureGroupHandler.php
  82. 2 1
      src/Monolog/Handler/ZendMonitorHandler.php
  83. 5 28
      src/Monolog/Logger.php
  84. 1 1
      src/Monolog/Processor/GitProcessor.php
  85. 1 1
      src/Monolog/Processor/IntrospectionProcessor.php
  86. 1 1
      src/Monolog/Processor/MemoryPeakUsageProcessor.php
  87. 1 1
      src/Monolog/Processor/MemoryProcessor.php
  88. 1 1
      src/Monolog/Processor/MemoryUsageProcessor.php
  89. 1 1
      src/Monolog/Processor/ProcessIdProcessor.php
  90. 1 1
      src/Monolog/Processor/PsrLogMessageProcessor.php
  91. 1 1
      src/Monolog/Processor/TagProcessor.php
  92. 1 1
      src/Monolog/Processor/UidProcessor.php
  93. 1 1
      src/Monolog/Processor/WebProcessor.php
  94. 1 1
      src/Monolog/Registry.php
  95. 4 2
      src/Monolog/Test/TestCase.php
  96. 1 1
      tests/Monolog/ErrorHandlerTest.php
  97. 1 1
      tests/Monolog/Formatter/ChromePHPFormatterTest.php
  98. 1 1
      tests/Monolog/Formatter/ElasticaFormatterTest.php
  99. 1 1
      tests/Monolog/Formatter/FlowdockFormatterTest.php
  100. 1 1
      tests/Monolog/Formatter/FluentdFormatterTest.php

+ 1 - 1
.php_cs

@@ -32,7 +32,7 @@ return PhpCsFixer\Config::create()
         'no_blank_lines_after_class_opening' => true,
         'no_blank_lines_after_phpdoc' => true,
         'no_blank_lines_between_uses' => true,
-        'no_duplicate_semicolons' => true,
+        'no_empty_statement' => true,
         'no_extra_consecutive_blank_lines' => true,
         'no_leading_import_slash' => true,
         'no_leading_namespace_whitespace' => true,

+ 1 - 1
composer.json

@@ -18,7 +18,7 @@
     },
     "require-dev": {
         "phpunit/phpunit": "^5.3",
-        "graylog2/gelf-php": "^1.0.1",
+        "graylog2/gelf-php": "1.3.x-dev",
         "sentry/sentry": "^0.13",
         "ruflin/elastica": ">=0.90 <3.0",
         "doctrine/couchdb": "~1.0@dev",

+ 5 - 3
src/Monolog/DateTimeImmutable.php

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -23,11 +23,13 @@ class DateTimeImmutable extends \DateTimeImmutable implements \JsonSerializable
 
     public function __construct($useMicroseconds, \DateTimeZone $timezone = null)
     {
-        $date = null;
+        $date = 'now';
         if ($useMicroseconds) {
+            // Circumvent DateTimeImmutable::createFromFormat() which always returns \DateTimeImmutable instead of `static`
+            // @link https://bugs.php.net/bug.php?id=60302
             $timestamp = microtime(true);
             $microseconds = sprintf("%06d", ($timestamp - floor($timestamp)) * 1000000);
-            $date = date('Y-m-d H:i:s.' . $microseconds, $timestamp);
+            $date = date('Y-m-d H:i:s.' . $microseconds, (int) $timestamp);
         }
         parent::__construct($date, $timezone);
 

+ 1 - 1
src/Monolog/ErrorHandler.php

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

+ 7 - 2
src/Monolog/Formatter/GelfMessageFormatter.php

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -68,7 +68,12 @@ class GelfMessageFormatter extends NormalizerFormatter
      */
     public function format(array $record)
     {
-        $record = parent::format($record);
+        if (isset($record['context'])) {
+            $record['context'] = parent::format($record['context']);
+        }
+        if (isset($record['extra'])) {
+            $record['extra'] = parent::format($record['extra']);
+        }
 
         if (!isset($record['datetime'], $record['message'], $record['level'])) {
             throw new \InvalidArgumentException('The record should at least contain datetime, message and level keys, '.var_export($record, true).' given');

+ 3 - 2
src/Monolog/Formatter/HtmlFormatter.php

@@ -1,4 +1,5 @@
-<?php
+<?php declare(strict_types=1);
+
 /*
  * This file is part of the Monolog package.
  *
@@ -87,7 +88,7 @@ class HtmlFormatter extends NormalizerFormatter
         $output .= '<table cellspacing="1" width="100%" class="monolog-output">';
 
         $output .= $this->addRow('Message', (string) $record['message']);
-        $output .= $this->addRow('Time', $record['datetime']->format($this->dateFormat));
+        $output .= $this->addRow('Time', $this->formatDate($record['datetime']));
         $output .= $this->addRow('Channel', $record['channel']);
         if ($record['context']) {
             $embeddedTable = '<table cellspacing="1" width="100%">';

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

+ 15 - 8
src/Monolog/Formatter/NormalizerFormatter.php

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -30,7 +30,7 @@ class NormalizerFormatter implements FormatterInterface
      */
     public function __construct(string $dateFormat = null)
     {
-        $this->dateFormat = $dateFormat;
+        $this->dateFormat = null === $dateFormat ? static::SIMPLE_DATE : $dateFormat;
         if (!function_exists('json_encode')) {
             throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s NormalizerFormatter');
         }
@@ -87,11 +87,7 @@ class NormalizerFormatter implements FormatterInterface
         }
 
         if ($data instanceof \DateTimeInterface) {
-            if ($data instanceof DateTimeImmutable) {
-                return (string) $data;
-            }
-
-            return $data->format($this->dateFormat ?: static::SIMPLE_DATE);
+            return $this->formatDate($data);
         }
 
         if (is_object($data)) {
@@ -271,7 +267,9 @@ class NormalizerFormatter implements FormatterInterface
         if (is_string($data) && !preg_match('//u', $data)) {
             $data = preg_replace_callback(
                 '/[\x80-\xFF]+/',
-                function ($m) { return utf8_encode($m[0]); },
+                function ($m) {
+                    return utf8_encode($m[0]);
+                },
                 $data
             );
             $data = str_replace(
@@ -281,4 +279,13 @@ class NormalizerFormatter implements FormatterInterface
             );
         }
     }
+
+    protected function formatDate(\DateTimeInterface $date)
+    {
+        if ($date instanceof DateTimeImmutable) {
+            return (string) $date;
+        }
+
+        return $date->format($this->dateFormat);
+    }
 }

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -83,7 +83,7 @@ abstract class AbstractSyslogHandler extends AbstractProcessingHandler
         }
 
         // convert textual description of facility to syslog constant
-        if (array_key_exists(strtolower($facility), $this->facilities)) {
+        if (is_string($facility) && array_key_exists(strtolower($facility), $this->facilities)) {
             $facility = $this->facilities[strtolower($facility)];
         } elseif (!in_array($facility, array_values($this->facilities), true)) {
             throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given');

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -58,7 +58,7 @@ class CouchDBHandler extends AbstractProcessingHandler
             ],
         ]);
 
-        if (false === @file_get_contents($url, null, $context)) {
+        if (false === @file_get_contents($url, false, $context)) {
             throw new \RuntimeException(sprintf('Could not connect to %s', $url));
         }
     }

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -144,7 +144,7 @@ class DeduplicationHandler extends BufferHandler
 
         while (!feof($handle)) {
             $log = fgets($handle);
-            if (substr($log, 0, 10) >= $timestampValidity) {
+            if ($log && substr($log, 0, 10) >= $timestampValidity) {
                 $validLogs[] = $log;
             }
         }

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -46,7 +46,7 @@ abstract class MailHandler extends AbstractProcessingHandler
      * @param string $content formatted email body to be sent
      * @param array  $records the array of log records that formed this content
      */
-    abstract protected function send($content, array $records);
+    abstract protected function send(string $content, array $records);
 
     /**
      * {@inheritdoc}

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -115,7 +115,7 @@ class NativeMailerHandler extends MailHandler
     /**
      * {@inheritdoc}
      */
-    protected function send($content, array $records)
+    protected function send(string $content, array $records)
     {
         $contentType = $this->getContentType() ?: ($this->isHtmlBody($content) ? 'text/html' : 'text/plain');
 

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

+ 3 - 2
src/Monolog/Handler/RotatingFileHandler.php

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -134,7 +134,8 @@ class RotatingFileHandler extends StreamHandler
             if (is_writable($file)) {
                 // suppress errors here as unlink() might fail if two processes
                 // are cleaning up/rotating at the same time
-                set_error_handler(function ($errno, $errstr, $errfile, $errline) {});
+                set_error_handler(function ($errno, $errstr, $errfile, $errline) {
+                });
                 unlink($file);
                 restore_error_handler();
             }

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -92,7 +92,7 @@ class SlackHandler extends SocketHandler
         $this->token = $token;
         $this->channel = $channel;
         $this->username = $username;
-        $this->iconEmoji = trim($iconEmoji, ':');
+        $this->iconEmoji = is_string($iconEmoji) ? trim($iconEmoji, ':') : null;
         $this->useAttachment = $useAttachment;
         $this->useShortAttachment = $useShortAttachment;
         $this->includeContextAndExtra = $includeContextAndExtra;

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
 
 use Monolog\Logger;
 use Monolog\Formatter\LineFormatter;
+use Swift_Message;
 
 /**
  * SwiftMailerHandler uses Swift_Mailer to send the emails
@@ -26,7 +27,7 @@ class SwiftMailerHandler extends MailHandler
 
     /**
      * @param \Swift_Mailer           $mailer  The mailer to use
-     * @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced
+     * @param callable|Swift_Message $message An example message for real messages, only the body will be replaced
      * @param int                     $level   The minimum logging level at which this handler will be triggered
      * @param Boolean                 $bubble  Whether the messages that are handled can bubble up the stack or not
      */
@@ -41,7 +42,7 @@ class SwiftMailerHandler extends MailHandler
     /**
      * {@inheritdoc}
      */
-    protected function send($content, array $records)
+    protected function send(string $content, array $records)
     {
         $this->mailer->send($this->buildMessage($content, $records));
     }
@@ -51,19 +52,19 @@ class SwiftMailerHandler extends MailHandler
      *
      * @param  string         $content formatted email body to be sent
      * @param  array          $records Log records that formed the content
-     * @return \Swift_Message
+     * @return Swift_Message
      */
-    protected function buildMessage($content, array $records)
+    protected function buildMessage(string $content, array $records): Swift_Message
     {
         $message = null;
-        if ($this->messageTemplate instanceof \Swift_Message) {
+        if ($this->messageTemplate instanceof Swift_Message) {
             $message = clone $this->messageTemplate;
             $message->generateId();
         } elseif (is_callable($this->messageTemplate)) {
             $message = call_user_func($this->messageTemplate, $content, $records);
         }
 
-        if (!$message instanceof \Swift_Message) {
+        if (!$message instanceof Swift_Message) {
             throw new \InvalidArgumentException('Could not resolve message as instance of Swift_Message or a callable returning it');
         }
 

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

+ 1 - 1
src/Monolog/Handler/SyslogUdp/UdpSocket.php

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

+ 2 - 1
src/Monolog/Handler/ZendMonitorHandler.php

@@ -1,4 +1,5 @@
-<?php
+<?php declare(strict_types=1);
+
 /*
  * This file is part of the Monolog package.
  *

+ 5 - 28
src/Monolog/Logger.php

@@ -1,15 +1,4 @@
-<?php
-
-/*
- * This file is part of the Monolog package.
- *
- * (c) Jordi Boggiano <j.boggiano@seld.be>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-declare(strict_types=1);
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -173,7 +162,7 @@ class Logger implements LoggerInterface
      *
      * @return static
      */
-    public function withName($name)
+    public function withName(string $name): self
     {
         $new = clone $this;
         $new->name = $name;
@@ -315,7 +304,8 @@ class Logger implements LoggerInterface
             return false;
         }
 
-        $ts = $this->createDateTime();
+        $dateTime = new DateTimeImmutable($this->microsecondTimestamps, $this->timezone);
+        $dateTime->setTimezone($this->timezone);
 
         $record = [
             'message' => $message,
@@ -323,7 +313,7 @@ class Logger implements LoggerInterface
             'level' => $level,
             'level_name' => $levelName,
             'channel' => $this->name,
-            'datetime' => $ts,
+            'datetime' => $dateTime,
             'extra' => [],
         ];
 
@@ -555,17 +545,4 @@ class Logger implements LoggerInterface
     {
         return $this->timezone;
     }
-
-    /**
-     * Circumvent DateTimeImmutable::createFromFormat() which always returns the native DateTime instead of the specialized one
-     *
-     * @link https://bugs.php.net/bug.php?id=60302
-     */
-    private function createDateTime(): DateTimeImmutable
-    {
-        $dateTime = new DateTimeImmutable($this->microsecondTimestamps, $this->timezone);
-        $dateTime->setTimezone($this->timezone);
-
-        return $dateTime;
-    }
 }

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

+ 1 - 1
src/Monolog/Registry.php

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.
@@ -59,7 +59,9 @@ class TestCase extends \PHPUnit_Framework_TestCase
         $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
         $formatter->expects($this->any())
             ->method('format')
-            ->will($this->returnCallback(function ($record) { return $record['message']; }));
+            ->will($this->returnCallback(function ($record) {
+                return $record['message'];
+            }));
 
         return $formatter;
     }

+ 1 - 1
tests/Monolog/ErrorHandlerTest.php

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

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

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 /*
  * This file is part of the Monolog package.

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно