diff --git a/ajax/reorder.php b/ajax/reorder.php index 3efae82a..8356c9da 100644 --- a/ajax/reorder.php +++ b/ajax/reorder.php @@ -44,6 +44,9 @@ $old_order = (int)$_POST['old_order']; $new_order = (int)$_POST['new_order']; +/** @var DBmysql $DB */ +global $DB; + // Retrieve id of field to update $field_iterator = $DB->request( [ diff --git a/composer.json b/composer.json index 2a585bb2..da444512 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,9 @@ "symfony/yaml": "^5.4" }, "require-dev": { - "glpi-project/tools": "^0.6", + "glpi-project/tools": "^0.7.1", "php-parallel-lint/php-parallel-lint": "^1.3", + "phpstan/phpstan": "^1.10", "squizlabs/php_codesniffer": "^3.6" }, "config": { diff --git a/composer.lock b/composer.lock index dd2eb416..faad12ad 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": "2a7360182e8cc8ad1b72d964a2117b49", + "content-hash": "5b54b981574317523605770d0cd75545", "packages": [ { "name": "symfony/deprecation-contracts", @@ -75,16 +75,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", "shasum": "" }, "require": { @@ -99,7 +99,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -137,7 +137,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" }, "funding": [ { @@ -153,20 +153,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/yaml", - "version": "v5.4.23", + "version": "v5.4.30", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "4cd2e3ea301aadd76a4172756296fe552fb45b0b" + "reference": "c6980e82a6656f6ebfabfd82f7585794cb122554" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/4cd2e3ea301aadd76a4172756296fe552fb45b0b", - "reference": "4cd2e3ea301aadd76a4172756296fe552fb45b0b", + "url": "https://api.github.com/repos/symfony/yaml/zipball/c6980e82a6656f6ebfabfd82f7585794cb122554", + "reference": "c6980e82a6656f6ebfabfd82f7585794cb122554", "shasum": "" }, "require": { @@ -212,7 +212,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v5.4.23" + "source": "https://github.com/symfony/yaml/tree/v5.4.30" }, "funding": [ { @@ -228,28 +228,32 @@ "type": "tidelift" } ], - "time": "2023-04-23T19:33:36+00:00" + "time": "2023-10-27T18:36:14+00:00" } ], "packages-dev": [ { "name": "glpi-project/tools", - "version": "0.6.4", + "version": "0.7.1", "source": { "type": "git", "url": "https://github.com/glpi-project/tools.git", - "reference": "8ef917fa2967e716eaed198bb803f418a80cd621" + "reference": "4bc5a725d9f4da0ee946ad3cbdd54a782d2f40fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/glpi-project/tools/zipball/8ef917fa2967e716eaed198bb803f418a80cd621", - "reference": "8ef917fa2967e716eaed198bb803f418a80cd621", + "url": "https://api.github.com/repos/glpi-project/tools/zipball/4bc5a725d9f4da0ee946ad3cbdd54a782d2f40fb", + "reference": "4bc5a725d9f4da0ee946ad3cbdd54a782d2f40fb", "shasum": "" }, "require": { "symfony/console": "^5.4 || ^6.0", "twig/twig": "^3.3" }, + "require-dev": { + "nikic/php-parser": "^4.13", + "phpstan/phpstan-src": "^1.10" + }, "bin": [ "bin/extract-locales", "bin/licence-headers-check", @@ -258,7 +262,7 @@ "type": "library", "autoload": { "psr-4": { - "Glpi\\": "src/" + "GlpiProject\\Tools\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -282,7 +286,7 @@ "issues": "https://github.com/glpi-project/tools/issues", "source": "https://github.com/glpi-project/tools" }, - "time": "2023-07-27T12:32:25+00:00" + "time": "2023-10-16T11:40:35+00:00" }, { "name": "php-parallel-lint/php-parallel-lint", @@ -341,6 +345,68 @@ }, "time": "2022-02-21T12:50:22+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.10.41", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "c6174523c2a69231df55bdc65b61655e72876d76" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c6174523c2a69231df55bdc65b61655e72876d76", + "reference": "c6174523c2a69231df55bdc65b61655e72876d76", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2023-11-05T12:57:57+00:00" + }, { "name": "psr/container", "version": "1.1.2", @@ -448,16 +514,16 @@ }, { "name": "symfony/console", - "version": "v5.4.26", + "version": "v5.4.28", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "b504a3d266ad2bb632f196c0936ef2af5ff6e273" + "reference": "f4f71842f24c2023b91237c72a365306f3c58827" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/b504a3d266ad2bb632f196c0936ef2af5ff6e273", - "reference": "b504a3d266ad2bb632f196c0936ef2af5ff6e273", + "url": "https://api.github.com/repos/symfony/console/zipball/f4f71842f24c2023b91237c72a365306f3c58827", + "reference": "f4f71842f24c2023b91237c72a365306f3c58827", "shasum": "" }, "require": { @@ -527,7 +593,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.26" + "source": "https://github.com/symfony/console/tree/v5.4.28" }, "funding": [ { @@ -543,20 +609,20 @@ "type": "tidelift" } ], - "time": "2023-07-19T20:11:33+00:00" + "time": "2023-08-07T06:12:30+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "511a08c03c1960e08a883f4cffcacd219b758354" + "reference": "875e90aeea2777b6f135677f618529449334a612" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/511a08c03c1960e08a883f4cffcacd219b758354", - "reference": "511a08c03c1960e08a883f4cffcacd219b758354", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/875e90aeea2777b6f135677f618529449334a612", + "reference": "875e90aeea2777b6f135677f618529449334a612", "shasum": "" }, "require": { @@ -568,7 +634,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -608,7 +674,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.28.0" }, "funding": [ { @@ -624,20 +690,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6" + "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6", - "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", + "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", "shasum": "" }, "require": { @@ -649,7 +715,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -692,7 +758,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" }, "funding": [ { @@ -708,20 +774,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + "reference": "42292d99c55abe617799667f454222c54c60e229" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", + "reference": "42292d99c55abe617799667f454222c54c60e229", "shasum": "" }, "require": { @@ -736,7 +802,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -775,7 +841,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" }, "funding": [ { @@ -791,20 +857,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-07-28T09:04:16+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9" + "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9", - "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fe2f306d1d9d346a7fee353d0d5012e401e984b5", + "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5", "shasum": "" }, "require": { @@ -813,7 +879,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -854,7 +920,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.28.0" }, "funding": [ { @@ -870,20 +936,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", "shasum": "" }, "require": { @@ -892,7 +958,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -937,7 +1003,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" }, "funding": [ { @@ -953,7 +1019,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/service-contracts", @@ -1040,16 +1106,16 @@ }, { "name": "symfony/string", - "version": "v5.4.26", + "version": "v5.4.29", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "1181fe9270e373537475e826873b5867b863883c" + "reference": "e41bdc93def20eaf3bfc1537c4e0a2b0680a152d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/1181fe9270e373537475e826873b5867b863883c", - "reference": "1181fe9270e373537475e826873b5867b863883c", + "url": "https://api.github.com/repos/symfony/string/zipball/e41bdc93def20eaf3bfc1537c4e0a2b0680a152d", + "reference": "e41bdc93def20eaf3bfc1537c4e0a2b0680a152d", "shasum": "" }, "require": { @@ -1106,7 +1172,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.26" + "source": "https://github.com/symfony/string/tree/v5.4.29" }, "funding": [ { @@ -1122,20 +1188,20 @@ "type": "tidelift" } ], - "time": "2023-06-28T12:46:07+00:00" + "time": "2023-09-13T11:47:41+00:00" }, { "name": "twig/twig", - "version": "v3.7.0", + "version": "v3.7.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "5cf942bbab3df42afa918caeba947f1b690af64b" + "reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/5cf942bbab3df42afa918caeba947f1b690af64b", - "reference": "5cf942bbab3df42afa918caeba947f1b690af64b", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/a0ce373a0ca3bf6c64b9e3e2124aca502ba39554", + "reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554", "shasum": "" }, "require": { @@ -1145,7 +1211,7 @@ }, "require-dev": { "psr/container": "^1.0|^2.0", - "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0" + "symfony/phpunit-bridge": "^5.4.9|^6.3" }, "type": "library", "autoload": { @@ -1181,7 +1247,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.7.0" + "source": "https://github.com/twigphp/Twig/tree/v3.7.1" }, "funding": [ { @@ -1193,7 +1259,7 @@ "type": "tidelift" } ], - "time": "2023-07-26T07:16:09+00:00" + "time": "2023-08-28T11:09:02+00:00" } ], "aliases": [], @@ -1208,5 +1274,5 @@ "platform-overrides": { "php": "7.4.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/front/commondropdown.form.php b/front/commondropdown.form.php index 06ae450a..cc20a260 100644 --- a/front/commondropdown.form.php +++ b/front/commondropdown.form.php @@ -30,7 +30,7 @@ include "../../../inc/includes.php"; if (preg_match('/[a-z]/i', $_REQUEST['ddtype']) !== 1) { - throw new \RuntimeException(sprintf('Invalid itemtype "%"', $_REQUEST['ddtype'])); + throw new \RuntimeException(sprintf('Invalid itemtype "%1$s"', $_REQUEST['ddtype'])); } $path = PLUGINFIELDS_FRONT_PATH . '/' . $_REQUEST['ddtype'] . '.form.php'; require_once $path; diff --git a/front/commondropdown.php b/front/commondropdown.php index d0f3f71b..ebd334be 100644 --- a/front/commondropdown.php +++ b/front/commondropdown.php @@ -30,7 +30,7 @@ include "../../../inc/includes.php"; if (preg_match('/[a-z]/i', $_REQUEST['ddtype']) !== 1) { - throw new \RuntimeException(sprintf('Invalid itemtype "%"', $_REQUEST['ddtype'])); + throw new \RuntimeException(sprintf('Invalid itemtype "%1$s"', $_REQUEST['ddtype'])); } $path = PLUGINFIELDS_FRONT_PATH . '/' . $_REQUEST['ddtype'] . '.php'; require_once $path; diff --git a/hook.php b/hook.php index 84f77f2f..62ffa5d9 100644 --- a/hook.php +++ b/hook.php @@ -246,12 +246,14 @@ function plugin_fields_getRuleActions($params = []) function plugin_fields_rule_matched($params = []) { + /** @var DBmysql $DB */ global $DB; $container = new PluginFieldsContainer(); switch ($params['sub_type']) { case "PluginFusioninventoryTaskpostactionRule": + /** @phpstan-ignore-next-line */ $agent = new PluginFusioninventoryAgent(); if (isset($params['input']['plugin_fusioninventory_agents_id'])) { @@ -319,6 +321,7 @@ function plugin_fields_giveItem($itemtype, $ID, $data, $num) */ function plugin_datainjection_populate_fields() { + /** @var array $INJECTABLE_TYPES */ global $INJECTABLE_TYPES; $container = new PluginFieldsContainer(); diff --git a/inc/container.class.php b/inc/container.class.php index 11e55ba0..00d67cf7 100644 --- a/inc/container.class.php +++ b/inc/container.class.php @@ -70,6 +70,7 @@ public function getForbiddenStandardMassiveAction() */ public static function installBaseData(Migration $migration, $version) { + /** @var DBmysql $DB */ global $DB; $default_charset = DBConnection::getDefaultCharset(); @@ -158,6 +159,7 @@ public static function installBaseData(Migration $migration, $version) */ public static function installUserData(Migration $migration, $version) { + /** @var DBmysql $DB */ global $DB; // -> 0.90-1.3: generated class moved @@ -337,6 +339,7 @@ public static function installUserData(Migration $migration, $version) public static function uninstall() { + /** @var DBmysql $DB */ global $DB; //uninstall container table and class @@ -474,6 +477,8 @@ public static function getSpecificValueToDisplay($field, $values, array $options } return $obj; } + + return ''; } @@ -487,7 +492,7 @@ public function getValueToSelect($field_id_or_search_options, $name = '', $value return Dropdown::showFromArray($name, self::getTypes(), $options); case $this->getTable() . '.itemtypes': $options['display'] = false; - return Dropdown::showFromArray($name, self::getItemtypes(), $options); + return Dropdown::showFromArray($name, self::getItemtypes(false), $options); } return parent::getValueToSelect($field_id_or_search_options, $name, $values, $options); @@ -661,6 +666,7 @@ public static function generateTemplate($fields) // phpcs:ignore PSR1.Methods.CamelCapsMethodName public function pre_deleteItem() { + /** @var DBmysql $DB */ global $DB; $_SESSION['delete_container'] = true; @@ -999,6 +1005,7 @@ public static function getTypes() public static function getEntries($type = 'tab', $full = false): array { + /** @var DBmysql $DB */ global $DB; $condition = [ @@ -1060,6 +1067,7 @@ public static function getEntries($type = 'tab', $full = false): array public static function getUsedItemtypes($type = 'all', $must_be_active = false) { + /** @var DBmysql $DB */ global $DB; $itemtypes = []; $where = []; @@ -1114,6 +1122,8 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) } return $tabs_entries; } + + return ''; } @@ -1133,6 +1143,8 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ return PluginFieldsField::showForTabContainer($data['id'], $item); } } + + return true; } /** @@ -1146,6 +1158,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ */ public function updateFieldsValues($data, $itemtype, $massiveaction = false) { + /** @var DBmysql $DB */ global $DB; if (self::validateValues($data, $itemtype, $massiveaction) === false) { @@ -1206,6 +1219,7 @@ public function updateFieldsValues($data, $itemtype, $massiveaction = false) private function addRichTextFiles(CommonDBTM $object): void { + /** @var DBmysql $DB */ global $DB; $richtext_fields_iterator = $DB->request([ @@ -1383,6 +1397,7 @@ public static function constructHistory( */ public static function validateValues($data, $itemtype, $massiveaction) { + /** @var DBmysql $DB */ global $DB; $valid = true; @@ -1576,6 +1591,8 @@ public static function postItemAdd(CommonDBTM $item) } return $item->input = []; } + + return true; } /** @@ -1601,6 +1618,8 @@ public static function preItemUpdate(CommonDBTM $item) } return $item->input = []; } + + return true; } @@ -1766,6 +1785,7 @@ private static function populateData($c_id, CommonDBTM $item) public static function getAddSearchOptions($itemtype, $containers_id = false) { + /** @var DBmysql $DB */ global $DB; $opt = []; diff --git a/inc/containerdisplaycondition.class.php b/inc/containerdisplaycondition.class.php index a06ee833..ac677094 100644 --- a/inc/containerdisplaycondition.class.php +++ b/inc/containerdisplaycondition.class.php @@ -56,6 +56,7 @@ class PluginFieldsContainerDisplayCondition extends CommonDBChild */ public static function installBaseData(Migration $migration, $version) { + /** @var DBmysql $DB */ global $DB; $default_charset = DBConnection::getDefaultCharset(); $default_collation = DBConnection::getDefaultCollation(); @@ -142,6 +143,7 @@ public static function getConditionName($condition) public static function uninstall() { + /** @var DBmysql $DB */ global $DB; $DB->query("DROP TABLE IF EXISTS `" . self::getTable() . "`"); return true; @@ -175,6 +177,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ public static function getDisplayConditionForContainer(int $container_id): array { + /** @var DBmysql $DB */ global $DB; $iterator = $DB->request([ 'SELECT' => [ @@ -196,8 +199,11 @@ public static function getDisplayConditionForContainer(int $container_id): array private static function getItemtypesForContainer(int $container_id): array { + /** @var DBmysql $DB */ global $DB; + $results = []; + $iterator = $DB->request([ 'SELECT' => ['itemtypes'], 'FROM' => PluginFieldsContainer::getTable(), @@ -212,9 +218,9 @@ private static function getItemtypesForContainer(int $container_id): array foreach ($itemtypes as $itemtype) { $results[$itemtype] = $itemtype::getTypeName(); } - return $results; } - return []; + + return $results; } @@ -551,6 +557,8 @@ public function showForm($ID, array $options = []) : self::removeBlackListedOption(Search::getOptions($this->fields['itemtype']), $this->fields['itemtype']), ]; TemplateRenderer::getInstance()->display('@fields/forms/container_display_condition.html.twig', $twig_params); + + return true; } public function getCloneRelations(): array diff --git a/inc/dropdown.class.php b/inc/dropdown.class.php index 4623b24e..7b1f36f8 100644 --- a/inc/dropdown.class.php +++ b/inc/dropdown.class.php @@ -87,6 +87,7 @@ public static function installUserData(Migration $migration, $version) public static function uninstall() { + /** @var DBmysql $DB */ global $DB; //remove dropdown tables and files diff --git a/inc/field.class.php b/inc/field.class.php index a3c5bbcf..80fb1859 100644 --- a/inc/field.class.php +++ b/inc/field.class.php @@ -63,6 +63,7 @@ public function getForbiddenStandardMassiveAction() */ public static function installBaseData(Migration $migration, $version) { + /** @var DBmysql $DB */ global $DB; $default_charset = DBConnection::getDefaultCharset(); @@ -170,6 +171,7 @@ public static function installBaseData(Migration $migration, $version) */ private static function migrateToStableSO(Migration $migration): void { + /** @var DBmysql $DB */ global $DB; // Flatten itemtype list @@ -229,6 +231,7 @@ private static function migrateToStableSO(Migration $migration): void public static function uninstall() { + /** @var DBmysql $DB */ global $DB; $DB->query("DROP TABLE IF EXISTS `" . self::getTable() . "`"); @@ -272,7 +275,7 @@ public function prepareInputForAdd($input) //reject adding for same dropdown on same bloc if (!empty($found)) { - Session::AddMessageAfterRedirect(__("You cannot add same field 'dropdown' on same bloc", 'fields', false, ERROR)); + Session::AddMessageAfterRedirect(__("You cannot add same field 'dropdown' on same bloc", 'fields'), false, ERROR); return false; } @@ -395,6 +398,7 @@ public function pre_deleteItem() // phpcs:ignore PSR1.Methods.CamelCapsMethodName public function post_purgeItem() { + /** @var DBmysql $DB */ global $DB; $table = getTableForItemType(__CLASS__); @@ -482,6 +486,7 @@ public function prepareName($input, bool $prevent_duplicated = true) */ public function getNextRanking() { + /** @var DBmysql $DB */ global $DB; $iterator = $DB->request([ @@ -538,6 +543,10 @@ public function defineTabs($options = []) public function showSummary($container) { + /** + * @var DBmysql $DB + * @var array $CFG_GLPI + */ global $DB, $CFG_GLPI; $cID = $container->fields['id']; @@ -676,8 +685,8 @@ public function showForm($ID, $options = []) { $rand = mt_rand(); + $container = new PluginFieldsContainer(); if (isset($options['parent_id']) && !empty($options['parent_id'])) { - $container = new PluginFieldsContainer(); $container->getFromDB($options['parent_id']); } else if ( isset($options['parent']) @@ -697,7 +706,7 @@ public function showForm($ID, $options = []) } $this->initForm($ID, $options); - $this->showFormHeader($ID, $options); + $this->showFormHeader($options); echo "