2
0
Jordi Boggiano 1 жил өмнө
parent
commit
b4a48dd3ee

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

@@ -72,7 +72,7 @@ class RedisHandler extends AbstractProcessingHandler
             $mode = \defined('Redis::MULTI') ? Redis::MULTI : 1;
             $this->redisClient->multi($mode)
                 ->rPush($this->redisKey, $record->formatted)
-                ->lTrim($this->redisKey, -$this->capSize, -1)
+                ->ltrim($this->redisKey, -$this->capSize, -1)
                 ->exec();
         } else {
             $redisKey = $this->redisKey;

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

@@ -179,7 +179,7 @@ class TestHandler extends AbstractProcessingHandler
      */
     public function __call(string $method, array $args): bool
     {
-        if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
+        if ((bool) preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches)) {
             $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
             $level = \constant(Level::class.'::' . $matches[2]);
             $callback = [$this, $genericMethod];

+ 3 - 2
src/Monolog/Utils.php

@@ -200,6 +200,7 @@ final class Utils
             $data = preg_replace_callback(
                 '/[\x80-\xFF]+/',
                 function (array $m): string {
+                    // @phpstan-ignore function.deprecated
                     return \function_exists('mb_convert_encoding') ? mb_convert_encoding($m[0], 'UTF-8', 'ISO-8859-1') : utf8_encode($m[0]);
                 },
                 $data
@@ -234,12 +235,12 @@ final class Utils
             return (int) $val;
         }
 
-        if (preg_match('/^\s*(?<val>\d+)(?:\.\d+)?\s*(?<unit>[gmk]?)\s*$/i', $val, $match) !== 1) {
+        if (!(bool) preg_match('/^\s*(?<val>\d+)(?:\.\d+)?\s*(?<unit>[gmk]?)\s*$/i', $val, $match)) {
             return false;
         }
 
         $val = (int) $match['val'];
-        switch (strtolower($match['unit'] ?? '')) {
+        switch (strtolower($match['unit'])) {
             case 'g':
                 $val *= 1024;
                 // no break