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

Remove pointless json_encode availability checks (#1919)

Co-authored-by: Jens Hatlak <jens.hatlak@check24.de>
InvisibleSmiley 1 жил өмнө
parent
commit
63fdb125ab

+ 0 - 2
src/Monolog/Formatter/ElasticaFormatter.php

@@ -34,8 +34,6 @@ class ElasticaFormatter extends NormalizerFormatter
     /**
     /**
      * @param string  $index Elastic Search index name
      * @param string  $index Elastic Search index name
      * @param ?string $type  Elastic Search document type, deprecated as of Elastica 7
      * @param ?string $type  Elastic Search document type, deprecated as of Elastica 7
-     *
-     * @throws \RuntimeException If the function json_encode does not exist
      */
      */
     public function __construct(string $index, ?string $type)
     public function __construct(string $index, ?string $type)
     {
     {

+ 0 - 2
src/Monolog/Formatter/ElasticsearchFormatter.php

@@ -34,8 +34,6 @@ class ElasticsearchFormatter extends NormalizerFormatter
     /**
     /**
      * @param string $index Elasticsearch index name
      * @param string $index Elasticsearch index name
      * @param string $type  Elasticsearch record type
      * @param string $type  Elasticsearch record type
-     *
-     * @throws \RuntimeException If the function json_encode does not exist
      */
      */
     public function __construct(string $index, string $type)
     public function __construct(string $index, string $type)
     {
     {

+ 0 - 7
src/Monolog/Formatter/FluentdFormatter.php

@@ -42,15 +42,8 @@ class FluentdFormatter implements FormatterInterface
      */
      */
     protected bool $levelTag = false;
     protected bool $levelTag = false;
 
 
-    /**
-     * @throws \RuntimeException If the function json_encode does not exist
-     */
     public function __construct(bool $levelTag = false)
     public function __construct(bool $levelTag = false)
     {
     {
-        if (!\function_exists('json_encode')) {
-            throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s FluentdUnixFormatter');
-        }
-
         $this->levelTag = $levelTag;
         $this->levelTag = $levelTag;
     }
     }
 
 

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

@@ -42,8 +42,7 @@ class HtmlFormatter extends NormalizerFormatter
     }
     }
 
 
     /**
     /**
-     * @param  string|null       $dateFormat The format of the timestamp: one supported by DateTime::format
-     * @throws \RuntimeException If the function json_encode does not exist
+     * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
      */
      */
     public function __construct(?string $dateFormat = null)
     public function __construct(?string $dateFormat = null)
     {
     {

+ 0 - 2
src/Monolog/Formatter/JsonFormatter.php

@@ -38,8 +38,6 @@ class JsonFormatter extends NormalizerFormatter
 
 
     /**
     /**
      * @param self::BATCH_MODE_* $batchMode
      * @param self::BATCH_MODE_* $batchMode
-     *
-     * @throws \RuntimeException If the function json_encode does not exist
      */
      */
     public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = true, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false)
     public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = true, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false)
     {
     {

+ 0 - 2
src/Monolog/Formatter/LineFormatter.php

@@ -40,8 +40,6 @@ class LineFormatter extends NormalizerFormatter
      * @param string|null $format                The format of the message
      * @param string|null $format                The format of the message
      * @param string|null $dateFormat            The format of the timestamp: one supported by DateTime::format
      * @param string|null $dateFormat            The format of the timestamp: one supported by DateTime::format
      * @param bool        $allowInlineLineBreaks Whether to allow inline line breaks in log entries
      * @param bool        $allowInlineLineBreaks Whether to allow inline line breaks in log entries
-     *
-     * @throws \RuntimeException If the function json_encode does not exist
      */
      */
     public function __construct(?string $format = null, ?string $dateFormat = null, bool $allowInlineLineBreaks = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false)
     public function __construct(?string $format = null, ?string $dateFormat = null, bool $allowInlineLineBreaks = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false)
     {
     {

+ 0 - 2
src/Monolog/Formatter/LogstashFormatter.php

@@ -48,8 +48,6 @@ class LogstashFormatter extends NormalizerFormatter
      * @param string|null $systemName      The system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine
      * @param string|null $systemName      The system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine
      * @param string      $extraKey        The key for extra keys inside logstash "fields", defaults to extra
      * @param string      $extraKey        The key for extra keys inside logstash "fields", defaults to extra
      * @param string      $contextKey      The key for context keys inside logstash "fields", defaults to context
      * @param string      $contextKey      The key for context keys inside logstash "fields", defaults to context
-     *
-     * @throws \RuntimeException If the function json_encode does not exist
      */
      */
     public function __construct(string $applicationName, ?string $systemName = null, string $extraKey = 'extra', string $contextKey = 'context')
     public function __construct(string $applicationName, ?string $systemName = null, string $extraKey = 'extra', string $contextKey = 'context')
     {
     {

+ 1 - 5
src/Monolog/Formatter/NormalizerFormatter.php

@@ -34,15 +34,11 @@ class NormalizerFormatter implements FormatterInterface
     protected string $basePath = '';
     protected string $basePath = '';
 
 
     /**
     /**
-     * @param  string|null       $dateFormat The format of the timestamp: one supported by DateTime::format
-     * @throws \RuntimeException If the function json_encode does not exist
+     * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
      */
      */
     public function __construct(?string $dateFormat = null)
     public function __construct(?string $dateFormat = null)
     {
     {
         $this->dateFormat = null === $dateFormat ? static::SIMPLE_DATE : $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');
-        }
     }
     }
 
 
     /**
     /**

+ 0 - 2
src/Monolog/Formatter/WildfireFormatter.php

@@ -25,8 +25,6 @@ class WildfireFormatter extends NormalizerFormatter
 {
 {
     /**
     /**
      * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
      * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
-     *
-     * @throws \RuntimeException If the function json_encode does not exist
      */
      */
     public function __construct(?string $dateFormat = null)
     public function __construct(?string $dateFormat = null)
     {
     {

+ 0 - 6
src/Monolog/Handler/ChromePHPHandler.php

@@ -62,15 +62,9 @@ class ChromePHPHandler extends AbstractProcessingHandler
 
 
     protected static bool $sendHeaders = true;
     protected static bool $sendHeaders = true;
 
 
-    /**
-     * @throws \RuntimeException If the function json_encode does not exist
-     */
     public function __construct(int|string|Level $level = Level::Debug, bool $bubble = true)
     public function __construct(int|string|Level $level = Level::Debug, bool $bubble = true)
     {
     {
         parent::__construct($level, $bubble);
         parent::__construct($level, $bubble);
-        if (!\function_exists('json_encode')) {
-            throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s ChromePHPHandler');
-        }
     }
     }
 
 
     /**
     /**