From cdb4cc435c33e2028246dd9dd39d50aaa9eef946 Mon Sep 17 00:00:00 2001 From: Rom1-B Date: Thu, 20 Mar 2025 15:28:30 +0100 Subject: [PATCH] phpstan level 5 --- composer.json | 11 ++- composer.lock | 146 ++++++++++++++++++++++++++++++------- inc/profileright.class.php | 4 +- phpstan.neon | 2 +- setup.php | 4 +- 5 files changed, 134 insertions(+), 33 deletions(-) diff --git a/composer.json b/composer.json index 1e1cee1..994e2b1 100644 --- a/composer.json +++ b/composer.json @@ -4,10 +4,12 @@ "lcobucci/jwt": "^4.2" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.70", + "friendsofphp/php-cs-fixer": "^3.73", "glpi-project/tools": "^0.7.4", "php-parallel-lint/php-parallel-lint": "^1.4", - "phpstan/phpstan": "^2.1" + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-deprecation-rules": "^2.0" }, "provide": { "guzzlehttp/guzzle": "*", @@ -18,6 +20,9 @@ "platform": { "php": "7.4.0" }, - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "phpstan/extension-installer": true + } } } diff --git a/composer.lock b/composer.lock index 4747db9..c8e6374 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c4c0a201e59ced4e2d0846298d43b9a5", + "content-hash": "cfb4909d45de094e986b9105f1ca1517", "packages": [ { "name": "lcobucci/clock", @@ -543,16 +543,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.70.0", + "version": "v3.73.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "2ecd5aae0edc937f0d5aa4a22d1d705c6b2e084e" + "reference": "ffcb8200a42045e65049af7910cfd022f631b064" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/2ecd5aae0edc937f0d5aa4a22d1d705c6b2e084e", - "reference": "2ecd5aae0edc937f0d5aa4a22d1d705c6b2e084e", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/ffcb8200a42045e65049af7910cfd022f631b064", + "reference": "ffcb8200a42045e65049af7910cfd022f631b064", "shasum": "" }, "require": { @@ -560,6 +560,7 @@ "composer/semver": "^3.4", "composer/xdebug-handler": "^3.0.3", "ext-filter": "*", + "ext-hash": "*", "ext-json": "*", "ext-tokenizer": "*", "fidry/cpu-core-counter": "^1.2", @@ -582,18 +583,18 @@ "symfony/stopwatch": "^5.4 || ^6.4 || ^7.0" }, "require-dev": { - "facile-it/paraunit": "^1.3.1 || ^2.5", - "infection/infection": "^0.29.10", - "justinrainbow/json-schema": "^5.3 || ^6.0", + "facile-it/paraunit": "^1.3.1 || ^2.6", + "infection/infection": "^0.29.14", + "justinrainbow/json-schema": "^5.3 || ^6.2", "keradus/cli-executor": "^2.1", "mikey179/vfsstream": "^1.6.12", "php-coveralls/php-coveralls": "^2.7", "php-cs-fixer/accessible-object": "^1.1", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.6", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.6", - "phpunit/phpunit": "^9.6.22 || ^10.5.45 || ^11.5.7", - "symfony/var-dumper": "^5.4.48 || ^6.4.18 || ^7.2.0", - "symfony/yaml": "^5.4.45 || ^6.4.18 || ^7.2.0" + "phpunit/phpunit": "^9.6.22 || ^10.5.45 || ^11.5.12", + "symfony/var-dumper": "^5.4.48 || ^6.4.18 || ^7.2.3", + "symfony/yaml": "^5.4.45 || ^6.4.18 || ^7.2.3" }, "suggest": { "ext-dom": "For handling output formats in XML", @@ -634,7 +635,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.70.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.73.1" }, "funding": [ { @@ -642,7 +643,7 @@ "type": "github" } ], - "time": "2025-02-22T23:30:51+00:00" + "time": "2025-03-19T23:42:16+00:00" }, { "name": "glpi-project/tools", @@ -761,18 +762,66 @@ }, "time": "2024-03-27T12:14:49+00:00" }, + { + "name": "phpstan/extension-installer", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0 || ^2.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.4.3" + }, + "time": "2024-09-04T20:21:43+00:00" + }, { "name": "phpstan/phpstan", - "version": "2.1.6", + "version": "2.1.8", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "6eaec7c6c9e90dcfe46ad1e1ffa5171e2dab641c" + "reference": "f9adff3b87c03b12cc7e46a30a524648e497758f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6eaec7c6c9e90dcfe46ad1e1ffa5171e2dab641c", - "reference": "6eaec7c6c9e90dcfe46ad1e1ffa5171e2dab641c", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/f9adff3b87c03b12cc7e46a30a524648e497758f", + "reference": "f9adff3b87c03b12cc7e46a30a524648e497758f", "shasum": "" }, "require": { @@ -817,7 +866,54 @@ "type": "github" } ], - "time": "2025-02-19T15:46:42+00:00" + "time": "2025-03-09T09:30:48+00:00" + }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/1cc1259cb91ee4cfbb5c39bca9f635f067c910b4", + "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.1" + }, + "time": "2024-11-28T21:56:36+00:00" }, { "name": "psr/container", @@ -2933,16 +3029,16 @@ }, { "name": "twig/twig", - "version": "v3.11.2", + "version": "v3.11.3", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "5b580ec1882b54c98cbd8c0f8a3ca5d1904db6b1" + "reference": "3b06600ff3abefaf8ff55d5c336cd1c4253f8c7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/5b580ec1882b54c98cbd8c0f8a3ca5d1904db6b1", - "reference": "5b580ec1882b54c98cbd8c0f8a3ca5d1904db6b1", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/3b06600ff3abefaf8ff55d5c336cd1c4253f8c7e", + "reference": "3b06600ff3abefaf8ff55d5c336cd1c4253f8c7e", "shasum": "" }, "require": { @@ -2997,7 +3093,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.11.2" + "source": "https://github.com/twigphp/Twig/tree/v3.11.3" }, "funding": [ { @@ -3009,7 +3105,7 @@ "type": "tidelift" } ], - "time": "2024-11-06T18:50:16+00:00" + "time": "2024-11-07T12:34:41+00:00" } ], "aliases": [], @@ -3024,5 +3120,5 @@ "platform-overrides": { "php": "7.4.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/inc/profileright.class.php b/inc/profileright.class.php index f9bbb83..87f1fd9 100644 --- a/inc/profileright.class.php +++ b/inc/profileright.class.php @@ -290,7 +290,7 @@ public static function install(Migration $migration) PRIMARY KEY (`id`), UNIQUE `profiles_id_dashboard_uuid` (`profiles_id`, `dashboard_uuid`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; - $DB->query($query) or die($DB->error()); + $DB->doQuery($query) or die($DB->error()); } } @@ -304,6 +304,6 @@ public static function uninstall() /** @var DBmysql $DB */ global $DB; - $DB->query('DROP TABLE IF EXISTS `' . self::getTable() . '`'); + $DB->doQuery('DROP TABLE IF EXISTS `' . self::getTable() . '`'); } } diff --git a/phpstan.neon b/phpstan.neon index ba0ed17..455f2e7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,7 @@ parameters: parallel: maximumNumberOfProcesses: 2 - level: 3 + level: 5 bootstrapFiles: - ../../inc/based_config.php paths: diff --git a/setup.php b/setup.php index 3f82d51..bc4b9cb 100644 --- a/setup.php +++ b/setup.php @@ -31,7 +31,7 @@ define('PLUGIN_METABASE_VERSION', '1.3.3'); // Minimal GLPI version, inclusive -define('PLUGIN_METABASE_MIN_GLPI', '10.0.0'); +define('PLUGIN_METABASE_MIN_GLPI', '10.0.11'); // Maximum GLPI version, exclusive define('PLUGIN_METABASE_MAX_GLPI', '10.0.99'); @@ -143,7 +143,7 @@ function metabaseGetIdByField($itemtype = '', $field = '', $value = '') $query = 'SELECT `id` FROM `' . $itemtype::getTable() . "` WHERE `$field` = '" . addslashes($value) . "'"; - $result = $DB->query($query); + $result = $DB->doQuery($query); if ($DB->numrows($result) == 1) { return $DB->result($result, 0, 'id');