Bläddra i källkod

Fix phpstan errors, update baseline

Jordi Boggiano 2 år sedan
förälder
incheckning
8941155d2f
3 ändrade filer med 6 tillägg och 35 borttagningar
  1. 2 32
      phpstan-baseline.neon
  2. 3 2
      src/Monolog/Handler/FingersCrossedHandler.php
  3. 1 1
      src/Monolog/Utils.php

+ 2 - 32
phpstan-baseline.neon

@@ -15,16 +15,6 @@ parameters:
 			count: 1
 			path: src/Monolog/Formatter/WildfireFormatter.php
 
-		-
-			message: "#^Instanceof between Monolog\\\\Handler\\\\HandlerInterface and Monolog\\\\Handler\\\\HandlerInterface will always evaluate to true\\.$#"
-			count: 1
-			path: src/Monolog/Handler/FilterHandler.php
-
-		-
-			message: "#^Instanceof between Monolog\\\\Handler\\\\HandlerInterface and Monolog\\\\Handler\\\\HandlerInterface will always evaluate to true\\.$#"
-			count: 1
-			path: src/Monolog/Handler/FingersCrossedHandler.php
-
 		-
 			message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
 			count: 1
@@ -50,11 +40,6 @@ parameters:
 			count: 1
 			path: src/Monolog/Handler/MandrillHandler.php
 
-		-
-			message: "#^Instanceof between Swift_Message and Swift_Message will always evaluate to true\\.$#"
-			count: 1
-			path: src/Monolog/Handler/MandrillHandler.php
-
 		-
 			message: "#^Parameter \\$message of method Monolog\\\\Handler\\\\MandrillHandler\\:\\:__construct\\(\\) has invalid type Swift_Message\\.$#"
 			count: 3
@@ -66,9 +51,9 @@ parameters:
 			path: src/Monolog/Handler/MandrillHandler.php
 
 		-
-			message: "#^Instanceof between Monolog\\\\Handler\\\\HandlerInterface and Monolog\\\\Handler\\\\HandlerInterface will always evaluate to true\\.$#"
+			message: "#^Negated boolean expression is always false\\.$#"
 			count: 1
-			path: src/Monolog/Handler/SamplingHandler.php
+			path: src/Monolog/Handler/SyslogHandler.php
 
 		-
 			message: "#^Variable property access on \\$this\\(Monolog\\\\LogRecord\\)\\.$#"
@@ -95,22 +80,7 @@ parameters:
 			count: 1
 			path: src/Monolog/Logger.php
 
-		-
-			message: "#^Comparison operation \"\\<\" between int\\<1, 32\\> and 1 is always false\\.$#"
-			count: 1
-			path: src/Monolog/Processor/UidProcessor.php
-
-		-
-			message: "#^Comparison operation \"\\>\" between int\\<1, 32\\> and 32 is always false\\.$#"
-			count: 1
-			path: src/Monolog/Processor/UidProcessor.php
-
 		-
 			message: "#^Parameter \\#1 \\$length of function random_bytes expects int\\<1, max\\>, int given\\.$#"
 			count: 1
 			path: src/Monolog/Processor/UidProcessor.php
-
-		-
-			message: "#^Parameter \\#2 \\$callback of function preg_replace_callback expects callable\\(array\\<int\\|string, string\\>\\)\\: string, Closure\\(mixed\\)\\: array\\<int, string\\>\\|string\\|false given\\.$#"
-			count: 1
-			path: src/Monolog/Utils.php

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

@@ -181,8 +181,9 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
     private function flushBuffer(): void
     {
         if (null !== $this->passthruLevel) {
-            $this->buffer = array_filter($this->buffer, function ($record) {
-                return $this->passthruLevel->includes($record->level);
+            $passthruLevel = $this->passthruLevel;
+            $this->buffer = array_filter($this->buffer, static function ($record) use ($passthruLevel) {
+                return $passthruLevel->includes($record->level);
             });
             if (count($this->buffer) > 0) {
                 $this->getHandler(end($this->buffer))->handleBatch($this->buffer);

+ 1 - 1
src/Monolog/Utils.php

@@ -199,7 +199,7 @@ final class Utils
         if (is_string($data) && preg_match('//u', $data) !== 1) {
             $data = preg_replace_callback(
                 '/[\x80-\xFF]+/',
-                function ($m) {
+                function (array $m): string {
                     return function_exists('mb_convert_encoding') ? mb_convert_encoding($m[0], 'UTF-8', 'ISO-8859-1') : utf8_encode($m[0]);
                 },
                 $data