Browse Source

Add baseline for php8.2

Jordi Boggiano 1 year ago
parent
commit
11075bc016

+ 1 - 0
.github/workflows/phpstan.yml

@@ -17,6 +17,7 @@ jobs:
       matrix:
         php-version:
           - "8.1"
+          - latest
 
     steps:
       - uses: actions/checkout@v4

+ 6 - 0
phpstan-baseline-8.2.neon

@@ -0,0 +1,6 @@
+parameters:
+	ignoreErrors:
+		-
+			message: "#^Call to deprecated function utf8_encode\\(\\)\\.$#"
+			count: 1
+			path: src/Monolog/Utils.php

+ 10 - 0
phpstan-ignore-by-php-version.neon.php

@@ -0,0 +1,10 @@
+<?php declare(strict_types = 1);
+
+$includes = [];
+if (PHP_VERSION_ID >= 80200) {
+    $includes[] = __DIR__ . '/phpstan-baseline-8.2.neon';
+}
+
+$config['includes'] = $includes;
+
+return $config;

+ 1 - 0
phpstan.neon.dist

@@ -28,5 +28,6 @@ parameters:
 
 includes:
     - phpstan-baseline.neon
+    - phpstan-ignore-by-php-version.neon.php
     - vendor/phpstan/phpstan-strict-rules/rules.neon
     - vendor/phpstan/phpstan-deprecation-rules/rules.neon

+ 3 - 2
src/Monolog/Utils.php

@@ -200,8 +200,9 @@ 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]);
+                    return \function_exists('mb_convert_encoding')
+                        ? mb_convert_encoding($m[0], 'UTF-8', 'ISO-8859-1')
+                        : (\function_exists('utf8_encode') ? utf8_encode($m[0]) : '');
                 },
                 $data
             );