diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 8be7f87c6..90568ba4a 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -17,6 +17,7 @@ jobs: matrix: php-version: - "8.1" + - latest steps: - uses: actions/checkout@v4 diff --git a/phpstan-baseline-8.2.neon b/phpstan-baseline-8.2.neon new file mode 100644 index 000000000..6ee8a2f38 --- /dev/null +++ b/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 diff --git a/phpstan-ignore-by-php-version.neon.php b/phpstan-ignore-by-php-version.neon.php new file mode 100644 index 000000000..b217bbffd --- /dev/null +++ b/phpstan-ignore-by-php-version.neon.php @@ -0,0 +1,10 @@ += 80200) { + $includes[] = __DIR__ . '/phpstan-baseline-8.2.neon'; +} + +$config['includes'] = $includes; + +return $config; diff --git a/phpstan.neon.dist b/phpstan.neon.dist index cb82f5955..ea9eab772 100644 --- a/phpstan.neon.dist +++ b/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 diff --git a/src/Monolog/Utils.php b/src/Monolog/Utils.php index c09a01736..75d484b64 100644 --- a/src/Monolog/Utils.php +++ b/src/Monolog/Utils.php @@ -200,8 +200,9 @@ 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]); + 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 );