diff --git a/src/Monolog/Handler/RedisHandler.php b/src/Monolog/Handler/RedisHandler.php index 66cb324f5..c40d97c61 100644 --- a/src/Monolog/Handler/RedisHandler.php +++ b/src/Monolog/Handler/RedisHandler.php @@ -72,7 +72,7 @@ protected function writeCapped(LogRecord $record): void $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; diff --git a/src/Monolog/Handler/TestHandler.php b/src/Monolog/Handler/TestHandler.php index a98389b95..d410dd9ae 100644 --- a/src/Monolog/Handler/TestHandler.php +++ b/src/Monolog/Handler/TestHandler.php @@ -179,7 +179,7 @@ protected function write(LogRecord $record): void */ 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]; diff --git a/src/Monolog/Utils.php b/src/Monolog/Utils.php index 79ea96ca3..c09a01736 100644 --- a/src/Monolog/Utils.php +++ b/src/Monolog/Utils.php @@ -200,6 +200,7 @@ private static function detectAndCleanUtf8(&$data): void $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 @@ public static function expandIniShorthandBytes($val) return (int) $val; } - if (preg_match('/^\s*(?\d+)(?:\.\d+)?\s*(?[gmk]?)\s*$/i', $val, $match) !== 1) { + if (!(bool) preg_match('/^\s*(?\d+)(?:\.\d+)?\s*(?[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