Skip to content

Commit a355e61

Browse files
authored
phpstan level 5 (#931)
1 parent a441a19 commit a355e61

File tree

9 files changed

+137
-36
lines changed

9 files changed

+137
-36
lines changed

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
"friendsofphp/php-cs-fixer": "^3.70",
88
"glpi-project/tools": "^0.7.4",
99
"php-parallel-lint/php-parallel-lint": "^1.4",
10-
"phpstan/phpstan": "^2.1"
10+
"phpstan/extension-installer": "^1.4",
11+
"phpstan/phpstan": "^2.1",
12+
"phpstan/phpstan-deprecation-rules": "^2.0"
1113
},
1214
"config": {
1315
"optimize-autoloader": true,
1416
"platform": {
1517
"php": "7.4.0"
1618
},
17-
"sort-packages": true
19+
"sort-packages": true,
20+
"allow-plugins": {
21+
"phpstan/extension-installer": true
22+
}
1823
}
1924
}

composer.lock

Lines changed: 115 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/container.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static function installBaseData(Migration $migration, $version)
9696
PRIMARY KEY (`id`),
9797
KEY `entities_id` (`entities_id`)
9898
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
99-
$DB->query($query) or die($DB->error());
99+
$DB->doQuery($query) or die($DB->error());
100100
}
101101

102102
// multiple itemtype for one container
@@ -309,7 +309,7 @@ public static function installUserData(Migration $migration, $version)
309309
}
310310

311311
//drop old table
312-
$DB->query('DROP TABLE ' . $osdata::getTable());
312+
$DB->doQuery('DROP TABLE ' . $osdata::getTable());
313313
} else {
314314
$DB->update(
315315
'glpi_plugin_fields_containers',
@@ -372,7 +372,7 @@ public static function uninstall()
372372
}
373373

374374
//drop global container table
375-
$DB->query('DROP TABLE IF EXISTS `' . self::getTable() . '`');
375+
$DB->doQuery('DROP TABLE IF EXISTS `' . self::getTable() . '`');
376376

377377
//delete display preferences for this item
378378
$pref = new DisplayPreference();
@@ -740,7 +740,7 @@ public function pre_deleteItem()
740740
} else {
741741
//class does not exists; try to remove any existing table
742742
$tablename = getTableForItemType($classname);
743-
$DB->query("DROP TABLE IF EXISTS `$tablename`");
743+
$DB->doQuery("DROP TABLE IF EXISTS `$tablename`");
744744
}
745745

746746
//clean session

inc/containerdisplaycondition.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static function installBaseData(Migration $migration, $version)
7777
PRIMARY KEY (`id`),
7878
KEY `plugin_fields_containers_id_itemtype` (`plugin_fields_containers_id`, `itemtype`)
7979
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
80-
$DB->query($query) or die($DB->error());
80+
$DB->doQuery($query) or die($DB->error());
8181
}
8282

8383
return true;
@@ -145,7 +145,7 @@ public static function uninstall()
145145
{
146146
/** @var DBmysql $DB */
147147
global $DB;
148-
$DB->query('DROP TABLE IF EXISTS `' . self::getTable() . '`');
148+
$DB->doQuery('DROP TABLE IF EXISTS `' . self::getTable() . '`');
149149

150150
return true;
151151
}

inc/field.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static function installBaseData(Migration $migration, $version)
9292
KEY `is_active` (`is_active`),
9393
KEY `is_readonly` (`is_readonly`)
9494
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
95-
$DB->query($query) or die($DB->error());
95+
$DB->doQuery($query) or die($DB->error());
9696
}
9797

9898
$migration->displayMessage("Updating $table");
@@ -233,7 +233,7 @@ public static function uninstall()
233233
/** @var DBmysql $DB */
234234
global $DB;
235235

236-
$DB->query('DROP TABLE IF EXISTS `' . self::getTable() . '`');
236+
$DB->doQuery('DROP TABLE IF EXISTS `' . self::getTable() . '`');
237237

238238
return true;
239239
}

inc/labeltranslation.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static function installBaseData(Migration $migration, $version)
6969
KEY `language` (`language`),
7070
UNIQUE KEY `unicity` (`itemtype`, `items_id`, `language`)
7171
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
72-
$DB->query($query) or die($DB->error());
72+
$DB->doQuery($query) or die($DB->error());
7373
}
7474

7575
if ($DB->fieldExists($table, 'plugin_fields_itemtype')) {
@@ -94,7 +94,7 @@ public static function uninstall()
9494
/** @var DBmysql $DB */
9595
global $DB;
9696

97-
$DB->query('DROP TABLE IF EXISTS `' . self::getTable() . '`');
97+
$DB->doQuery('DROP TABLE IF EXISTS `' . self::getTable() . '`');
9898

9999
return true;
100100
}

inc/profile.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function installBaseData(Migration $migration, $version)
6868
KEY `profiles_id` (`profiles_id`),
6969
KEY `plugin_fields_containers_id` (`plugin_fields_containers_id`)
7070
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
71-
$DB->query($query) or die($DB->error());
71+
$DB->doQuery($query) or die($DB->error());
7272
}
7373

7474
return true;
@@ -79,7 +79,7 @@ public static function uninstall()
7979
/** @var DBmysql $DB */
8080
global $DB;
8181

82-
$DB->query('DROP TABLE IF EXISTS `' . self::getTable() . '`');
82+
$DB->doQuery('DROP TABLE IF EXISTS `' . self::getTable() . '`');
8383

8484
return true;
8585
}

inc/statusoverride.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static function installBaseData(Migration $migration, $version)
6969
PRIMARY KEY (`id`),
7070
KEY `plugin_fields_fields_id` (`plugin_fields_fields_id`)
7171
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
72-
$DB->query($query) or die($DB->error());
72+
$DB->doQuery($query) or die($DB->error());
7373
}
7474

7575
return true;
@@ -80,7 +80,7 @@ public static function uninstall()
8080
/** @var DBmysql $DB */
8181
global $DB;
8282

83-
$DB->query('DROP TABLE IF EXISTS `' . self::getTable() . '`');
83+
$DB->doQuery('DROP TABLE IF EXISTS `' . self::getTable() . '`');
8484

8585
return true;
8686
}

setup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
define('PLUGIN_FIELDS_VERSION', '1.21.19');
3232

3333
// Minimal GLPI version, inclusive
34-
define('PLUGIN_FIELDS_MIN_GLPI', '10.0.0');
34+
define('PLUGIN_FIELDS_MIN_GLPI', '10.0.11');
3535
// Maximum GLPI version, exclusive
3636
define('PLUGIN_FIELDS_MAX_GLPI', '10.0.99');
3737

0 commit comments

Comments
 (0)