From f1c7b454589d87ea4e90352259a86c87244f7bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Tue, 14 Jan 2025 00:08:00 +0100 Subject: [PATCH] lint --- .phpstan-baseline.php | 54 ++++++++++++++++++++++++++++--------------- phpstan.neon.dist | 2 ++ 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/.phpstan-baseline.php b/.phpstan-baseline.php index 22687952d1c..935a39d40f4 100644 --- a/.phpstan-baseline.php +++ b/.phpstan-baseline.php @@ -1801,12 +1801,6 @@ 'count' => 1, 'path' => __DIR__ . '/src/Fieldblacklist.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Property GLPI\\:\\:\\$error_handler is unused\\.$#', - 'identifier' => 'property.unused', - 'count' => 1, - 'path' => __DIR__ . '/src/GLPI.php', -]; $ignoreErrors[] = [ 'message' => '#^Default value of the parameter \\#1 \\$config_dir \\(null\\) of method GLPIKey\\:\\:__construct\\(\\) is incompatible with type string\\.$#', 'identifier' => 'parameter.defaultValue', @@ -2149,18 +2143,6 @@ 'count' => 1, 'path' => __DIR__ . '/src/Glpi/Api/HL/Search.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Default value of the parameter \\#2 \\$env \\(null\\) of method Glpi\\\\Application\\\\ErrorHandler\\:\\:__construct\\(\\) is incompatible with type string\\.$#', - 'identifier' => 'parameter.defaultValue', - 'count' => 1, - 'path' => __DIR__ . '/src/Glpi/Application/ErrorHandler.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Strict comparison using \\!\\=\\= between null and \'comment\'\\|\'error\' will always evaluate to true\\.$#', - 'identifier' => 'notIdentical.alwaysTrue', - 'count' => 1, - 'path' => __DIR__ . '/src/Glpi/Application/ErrorHandler.php', -]; $ignoreErrors[] = [ 'message' => '#^Default value of the parameter \\#2 \\$cachedir \\(null\\) of method Glpi\\\\Application\\\\View\\\\TemplateRenderer\\:\\:__construct\\(\\) is incompatible with type string\\.$#', 'identifier' => 'parameter.defaultValue', @@ -2587,6 +2569,30 @@ 'count' => 1, 'path' => __DIR__ . '/src/Glpi/Dropdown/Dropdown.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Class Glpi\\\\Error\\\\ErrorHandler extends @final class Symfony\\\\Component\\\\ErrorHandler\\\\ErrorHandler\\.$#', + 'identifier' => 'class.extendsFinalByPhpDoc', + 'count' => 1, + 'path' => __DIR__ . '/src/Glpi/Error/ErrorHandler.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Default value of the parameter \\#4 \\$env \\(null\\) of method Glpi\\\\Error\\\\ErrorHandler\\:\\:displayErrorMessage\\(\\) is incompatible with type string\\.$#', + 'identifier' => 'parameter.defaultValue', + 'count' => 1, + 'path' => __DIR__ . '/src/Glpi/Error/ErrorHandler.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Property Glpi\\\\Error\\\\ErrorHandler\\:\\:\\$env \\(string\\) does not accept null\\.$#', + 'identifier' => 'assign.propertyType', + 'count' => 1, + 'path' => __DIR__ . '/src/Glpi/Error/ErrorHandler.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Strict comparison using \\=\\=\\= between null and \'development\' will always evaluate to false\\.$#', + 'identifier' => 'identical.alwaysFalse', + 'count' => 1, + 'path' => __DIR__ . '/src/Glpi/Error/ErrorHandler.php', +]; $ignoreErrors[] = [ 'message' => '#^Method Glpi\\\\Form\\\\AccessControl\\\\FormAccessControl\\:\\:getTabNameForItem\\(\\) never returns array\\ so it can be removed from the return type\\.$#', 'identifier' => 'return.unusedType', @@ -3091,6 +3097,18 @@ 'count' => 1, 'path' => __DIR__ . '/src/Glpi/Kernel/Kernel.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Match arm comparison between null and \'development\' is always false\\.$#', + 'identifier' => 'match.alwaysFalse', + 'count' => 1, + 'path' => __DIR__ . '/src/Glpi/Log/GlpiLogHandler.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Match arm comparison between null and \'testing\' is always false\\.$#', + 'identifier' => 'match.alwaysFalse', + 'count' => 1, + 'path' => __DIR__ . '/src/Glpi/Log/GlpiLogHandler.php', +]; $ignoreErrors[] = [ 'message' => '#^Negated boolean expression is always true\\.$#', 'identifier' => 'booleanNot.alwaysTrue', diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 3b983683fa7..5313c2b1964 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -62,6 +62,8 @@ parameters: ignoreErrors: - '~Instantiated class XHProfRuns_Default not found~' - '~Instantiation of deprecated class Glpi\\Http\\HeaderlessStreamedResponse~' + - '~Call to( deprecated)? method logException\(\) of( deprecated)? class Glpi\\Application\\ErrorUtils.~' + - '~Call to( deprecated)? method outputExceptionMessage\(\) of( deprecated)? class Glpi\\Application\\ErrorUtils.~' - { message: '~Variable \$this might not be defined~', paths: [ 'inc/includes.php' ] } - { message: '~Call to protected method setAjax\(\) of class Glpi\\Controller\\LegacyFileLoadController.~', paths: [ 'ajax/*', 'front/*', 'inc/includes.php' ] } - { message: '~Access to protected property~', paths: [ 'front/dropdown.common.form.php' ] }