Skip to content

Commit 12694e9

Browse files
committed
Add missing types to inventory classes
1 parent 44e068c commit 12694e9

31 files changed

+254
-248
lines changed

src/Glpi/Inventory/Asset/Antivirus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ protected function getExisting(): array
114114
return $db_existing;
115115
}
116116

117-
public function handle()
117+
public function handle(): void
118118
{
119119
$db_antivirus = $this->getExisting();
120120
$value = $this->data;

src/Glpi/Inventory/Asset/Bios.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function prepare(): array
6666
return $this->data;
6767
}
6868

69-
public function handle()
69+
public function handle(): void
7070
{
7171
if (isset($this->main_item) && $this->main_item->isPartial()) {
7272
return;

src/Glpi/Inventory/Asset/Camera.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
use Item_DeviceCamera_ImageFormat;
4242
use Item_DeviceCamera_ImageResolution;
4343
use Item_Devices;
44+
use stdClass;
4445

4546
class Camera extends Device
4647
{
@@ -70,7 +71,7 @@ public function prepare(): array
7071
}
7172

7273

73-
protected function itemdeviceAdded(Item_Devices $itemdevice, $val)
74+
protected function itemdeviceAdded(Item_Devices $itemdevice, stdClass $val): void
7475
{
7576

7677
//handle resolutions
@@ -87,7 +88,7 @@ protected function itemdeviceAdded(Item_Devices $itemdevice, $val)
8788
}
8889
}
8990

90-
private function handleResolution($itemdevice, $val, $is_video = false)
91+
private function handleResolution(Item_Devices $itemdevice, array|string $val, bool $is_video = false): void
9192
{
9293
if (!is_array($val)) {
9394
$val = [$val];
@@ -120,7 +121,7 @@ private function handleResolution($itemdevice, $val, $is_video = false)
120121
}
121122
}
122123

123-
private function handleFormats($itemdevice, $val)
124+
private function handleFormats(Item_Devices $itemdevice, array|string $val): void
124125
{
125126
if (!is_array($val)) {
126127
$val = [$val];

src/Glpi/Inventory/Asset/Cartridge.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ protected function getExisting(): array
228228
return $db_existing;
229229
}
230230

231-
public function handle()
231+
public function handle(): void
232232
{
233233
$cartinfo = new Printer_CartridgeInfo();
234234
$db_cartridges = $this->getExisting();
@@ -249,7 +249,7 @@ public function handle()
249249
}
250250
}
251251

252-
if ((!$this->main_asset || !$this->main_asset->isPartial()) && count($db_cartridges) != 0) {
252+
if ((!isset($this->main_asset) || !$this->main_asset->isPartial()) && count($db_cartridges) != 0) {
253253
foreach (array_keys($db_cartridges) as $idtmp) {
254254
$cartinfo->delete(['id' => $idtmp], true);
255255
}

src/Glpi/Inventory/Asset/Controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
class Controller extends Device
4343
{
44-
protected $extra_data = ['ignored' => null];
44+
protected array $extra_data = ['ignored' => null];
4545

4646
public function prepare(): array
4747
{
@@ -80,7 +80,7 @@ public function prepare(): array
8080
return $this->data;
8181
}
8282

83-
public function handle()
83+
public function handle(): void
8484
{
8585
$data = $this->data;
8686

src/Glpi/Inventory/Asset/DatabaseInstance.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function getExisting(): array
101101
return $db_existing;
102102
}
103103

104-
public function handle()
104+
public function handle(): void
105105
{
106106
$rule = new RuleImportAssetCollection();
107107
$value = $this->data;

src/Glpi/Inventory/Asset/Device.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
use Glpi\Inventory\Conf;
3939
use Item_Devices;
40+
use stdClass;
4041

4142
use function Safe\strtotime;
4243

@@ -45,9 +46,12 @@ abstract class Device extends InventoryAsset
4546
/**
4647
* Get existing entries from database
4748
*
48-
* @return array
49+
* @param string $itemdevicetable Item_Device table
50+
* @param string $fk Foreign key column
51+
*
52+
* @return array<list<mixed>>
4953
*/
50-
protected function getExisting($itemdevicetable, $fk): array
54+
protected function getExisting(string $itemdevicetable, string $fk): array
5155
{
5256
global $DB;
5357

@@ -68,10 +72,8 @@ protected function getExisting($itemdevicetable, $fk): array
6872
return $db_existing;
6973
}
7074

71-
public function handle()
75+
public function handle(): void
7276
{
73-
global $DB;
74-
7577
$devicetypes = Item_Devices::getItemAffinities($this->item->getType());
7678

7779
$itemdevicetype = $this->getItemtype();
@@ -201,9 +203,9 @@ public function handle()
201203
}
202204
}
203205

204-
protected function itemdeviceAdded(Item_Devices $itemdevice, $val)
206+
protected function itemdeviceAdded(Item_Devices $itemdevice, stdClass $val): void
205207
{
206-
//to be overrided
208+
//to be overridden
207209
}
208210

209211
public function checkConf(Conf $conf): bool

src/Glpi/Inventory/Asset/Drive.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
use Glpi\Inventory\Conf;
4040
use Item_DeviceDrive;
41+
use stdClass;
4142

4243
use function Safe\preg_match;
4344

@@ -46,8 +47,8 @@ class Drive extends Device
4647
/** @var Conf */
4748
private Conf $conf;
4849

49-
private $harddrives;
50-
private $prepared_harddrives = [];
50+
private HardDrive $harddrives;
51+
private array $prepared_harddrives = [];
5152

5253
public function prepare(): array
5354
{
@@ -95,7 +96,7 @@ public function prepare(): array
9596
*
9697
* @return boolean
9798
*/
98-
public function isDrive($data)
99+
public function isDrive(stdClass $data): bool
99100
{
100101
$drives_regex = [
101102
'rom',
@@ -121,10 +122,10 @@ public function isDrive($data)
121122

122123
return false;
123124
}
124-
public function handle()
125+
public function handle(): void
125126
{
126127
parent::handle();
127-
if ($this->harddrives !== null) {
128+
if (isset($this->harddrives)) {
128129
$this->harddrives->handleLinks();
129130
$this->harddrives->handle();
130131
}

src/Glpi/Inventory/Asset/Environment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function getExisting(): array
7777
return $db_existing;
7878
}
7979

80-
public function handle()
80+
public function handle(): void
8181
{
8282
$itemEnv = new Item_Environment();
8383
$db_itemEnvs = $this->getExisting();
@@ -103,7 +103,7 @@ public function handle()
103103
}
104104
}
105105

106-
if ((!$this->main_asset || !$this->main_asset->isPartial()) && count($db_itemEnvs) != 0) {
106+
if ((!isset($this->main_asset) || !$this->main_asset->isPartial()) && count($db_itemEnvs) != 0) {
107107
// Delete Item_Environment in DB
108108
foreach ($db_itemEnvs as $dbid => $data) {
109109
if ($data['is_dynamic'] == 1) {

src/Glpi/Inventory/Asset/GraphicCard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
class GraphicCard extends Device
4242
{
43-
protected $ignored = ['controllers' => null];
43+
protected array $ignored = ['controllers' => null];
4444

4545
public function prepare(): array
4646
{

0 commit comments

Comments
 (0)