Skip to content

Commit eae5e02

Browse files
committed
Revert changes on public methods
1 parent a3e9edf commit eae5e02

File tree

13 files changed

+138
-49
lines changed

13 files changed

+138
-49
lines changed

src/Glpi/Inventory/Asset/Drive.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,12 @@ public function prepare(): array
9494
/**
9595
* Is current data a drive
9696
*
97+
* @param stdClass $data
98+
*
9799
* @return boolean
100+
* @final
98101
*/
99-
public function isDrive(stdClass $data): bool
102+
public function isDrive($data)
100103
{
101104
$drives_regex = [
102105
'rom',

src/Glpi/Inventory/Asset/InventoryAsset.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ public function getEntity(): int
126126
return $this->entities_id;
127127
}
128128

129-
public function maybeRecursive(): bool
129+
/**
130+
* @return bool
131+
*/
132+
public function maybeRecursive()
130133
{
131134
return true;
132135
}
@@ -185,7 +188,7 @@ public function setExtraData($data): InventoryAsset
185188
*
186189
* @return array
187190
*/
188-
public function getIgnored(string $type): array
191+
public function getIgnored($type): array
189192
{
190193
return $this->ignored[$type] ?? [];
191194
}
@@ -204,7 +207,7 @@ abstract public function checkConf(Conf $conf): bool;
204207
*
205208
* @return array
206209
*/
207-
public function handleLinks(): array
210+
public function handleLinks()
208211
{
209212
$foreignkey_itemtype = [];
210213

@@ -381,7 +384,7 @@ public function setEntityRecursive($is_recursive): InventoryAsset
381384
*
382385
* @return $this
383386
*/
384-
public function setRequestQuery(?string $query = Request::INVENT_QUERY): InventoryAsset
387+
public function setRequestQuery($query = Request::INVENT_QUERY): InventoryAsset
385388
{
386389
$this->request_query = $query;
387390
return $this;

src/Glpi/Inventory/Asset/InventoryNetworkPort.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ public function getNetworkPorts(): array
8585
* @param array $ports
8686
*
8787
* @return $this
88+
* @final
8889
*/
89-
public function addNetworkPorts(array $ports): self
90+
public function addNetworkPorts($ports): self
9091
{
9192
$this->ports += $ports;
9293
return $this;
@@ -112,8 +113,9 @@ private function isMainPartial(): bool
112113
* @param ?integer $items_id Item ID, will take current item per default
113114
*
114115
* @return void
116+
* @protected
115117
*/
116-
public function handlePorts(?string $itemtype = null, ?int $items_id = null)
118+
public function handlePorts($itemtype = null, $items_id = null)
117119
{
118120
if (!$this->checkPortsConf($this->conf)) {
119121
return;

src/Glpi/Inventory/Asset/NetworkCard.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,11 @@ public function checkConf(Conf $conf): bool
300300
return $conf->component_networkcard == 1 && parent::checkConf($conf);
301301
}
302302

303-
public function handlePorts(?string $itemtype = null, ?int $items_id = null): void
303+
/**
304+
* @protected
305+
* @final
306+
*/
307+
public function handlePorts($itemtype = null, $items_id = null)
304308
{
305309
//ports are handled from main asset in NetworkCard case
306310
return;

src/Glpi/Inventory/Asset/NetworkPort.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,10 @@ protected function portChanged(stdClass $port, int $netports_id): void
663663
* @param string $itemtype Item type
664664
* @param integer $rules_id Matched rule id, if any
665665
* @param integer|array $ports_id Matched port ids, if any
666+
*
667+
* @return void
666668
*/
667-
public function rulepassed($items_id, $itemtype, $rules_id, $ports_id = []): void
669+
public function rulepassed($items_id, $itemtype, $rules_id, $ports_id = [])
668670
{
669671
if (!is_array($ports_id)) {
670672
$ports_id = [$ports_id]; // Handle compatibility with previous signature.
@@ -805,7 +807,11 @@ protected function isLLDP(stdClass $port): bool
805807
return (bool) ($port->lldp ?? $port->cdp);
806808
}
807809

808-
public function handlePorts(?string $itemtype = null, ?int $items_id = null): void
810+
/**
811+
* @final
812+
* @protected
813+
*/
814+
public function handlePorts($itemtype = null, $items_id = null)
809815
{
810816
$mainasset = $this->extra_data[$this->main_asset::class];
811817

src/Glpi/Inventory/Asset/OperatingSystem.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ public function checkConf(Conf $conf): bool
210210
* Get current OS id
211211
*
212212
* @return string|integer
213+
* @final
213214
*/
214-
public function getId(): int|string
215+
public function getId()
215216
{
216217
return $this->operatingsystems_id;
217218
}

src/Glpi/Inventory/Asset/Software.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,14 @@ public function handle()
509509
}
510510
}
511511

512-
public function getOsForKey(stdClass $val): string|int
512+
/**
513+
* @protected
514+
*
515+
* @param stdClass $val
516+
*
517+
* @return string|int
518+
*/
519+
public function getOsForKey($val)
513520
{
514521
if ($val->operatingsystems_id > 0) {
515522
return $val->operatingsystems_id;
@@ -987,7 +994,7 @@ private function storeAssetLink(): void
987994
*
988995
* @return void
989996
*/
990-
public function logSoftwares(): void
997+
public function logSoftwares()
991998
{
992999
foreach ($this->added_versions as $software_data) {
9931000
Log::history(

src/Glpi/Inventory/Conf.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ public function knownInventoryExtensions(): array
179179
* @param array $files[filename => filepath] Files to import
180180
*
181181
* @return array [filename => [success => bool, message => string, asset => CommonDBTM]]
182+
* @final
182183
*/
183-
public function importFiles(array $files): array
184+
public function importFiles($files): array
184185
{
185186
$result = [];
186187

@@ -214,9 +215,12 @@ public function importFiles(array $files): array
214215
/**
215216
* Is an inventory known file
216217
*
218+
* @param string $name
219+
*
217220
* @return boolean
221+
* @final
218222
*/
219-
public function isInventoryFile(string $name): bool
223+
public function isInventoryFile($name): bool
220224
{
221225
return (bool) preg_match('/\.(' . implode('|', $this->knownInventoryExtensions()) . ')/i', $name);
222226
}
@@ -342,7 +346,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
342346
* @return true (Always true)
343347
* @copyright 2010-2022 by the FusionInventory Development Team. (Agent cleanup section)
344348
**/
345-
public function showConfigForm(): true
349+
public function showConfigForm()
346350
{
347351
global $CFG_GLPI, $PLUGIN_HOOKS;
348352

@@ -1104,7 +1108,7 @@ function changestatus() {
11041108
*
11051109
* @return boolean
11061110
*/
1107-
public function saveConf(array $values): bool
1111+
public function saveConf(array $values)
11081112
{
11091113
if (!Config::canUpdate()) {
11101114
return false;
@@ -1213,7 +1217,12 @@ public function __get(string $name)
12131217
}
12141218
}
12151219

1216-
public function getRights(string $interface = 'central'): array
1220+
/**
1221+
* @param string $interface
1222+
*
1223+
* @return array
1224+
*/
1225+
public function getRights($interface = 'central')
12171226
{
12181227
$values = [ READ => __('Read')];
12191228
$values[self::IMPORTFROMFILE] = ['short' => __('Import'),
@@ -1235,7 +1244,7 @@ public function getRights(string $interface = 'central'): array
12351244
*
12361245
* @return string
12371246
*/
1238-
public function buildInventoryFileName(string $itemtype, int $items_id, string $ext): string
1247+
public function buildInventoryFileName($itemtype, $items_id, $ext): string
12391248
{
12401249
$files_per_dir = 1000;
12411250

@@ -1296,7 +1305,7 @@ public static function getDefaults(): array
12961305
];
12971306
}
12981307

1299-
public static function getIcon(): string
1308+
public static function getIcon()
13001309
{
13011310
return "ti ti-adjustments";
13021311
}

src/Glpi/Inventory/Inventory.php

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class Inventory
143143
* @param integer $mode One of self::*_MODE
144144
* @param integer $format One of Request::*_MODE
145145
*/
146-
public function __construct(mixed $data = null, int $mode = self::FULL_MODE, int $format = Request::JSON_MODE)
146+
public function __construct($data = null, $mode = self::FULL_MODE, $format = Request::JSON_MODE)
147147
{
148148
$this->mode = $mode;
149149
$this->conf = new Conf();
@@ -154,7 +154,12 @@ public function __construct(mixed $data = null, int $mode = self::FULL_MODE, int
154154
}
155155
}
156156

157-
public function setMode(int $mode = self::FULL_MODE): Inventory
157+
/**
158+
* @param int $mode
159+
*
160+
* @return Inventory
161+
*/
162+
public function setMode($mode = self::FULL_MODE): Inventory
158163
{
159164
$this->mode = $mode;
160165
return $this;
@@ -168,7 +173,7 @@ public function setMode(int $mode = self::FULL_MODE): Inventory
168173
*
169174
* @return boolean
170175
*/
171-
public function setData($data, int $format = Request::JSON_MODE): bool
176+
public function setData($data, $format = Request::JSON_MODE): bool
172177
{
173178

174179
// Write inventory file
@@ -285,7 +290,7 @@ public function extractMetadata(): array
285290
/**
286291
* CONTACT request from agent
287292
*/
288-
public function contact(mixed $data): void
293+
public function contact($data)
289294
{
290295
$this->raw_data = $data;
291296
$this->extractMetadata();
@@ -301,7 +306,7 @@ public function contact(mixed $data): void
301306
*
302307
* @return bool
303308
*/
304-
public function doInventory(bool $test_rules = false): bool
309+
public function doInventory($test_rules = false)
305310
{
306311
global $DB;
307312

@@ -572,7 +577,7 @@ public function inError(): bool
572577
return (bool) count($this->errors);
573578
}
574579

575-
public static function getMenuContent(): array|false
580+
public static function getMenuContent()
576581
{
577582
if (!Session::haveRight(Conf::$rightname, Conf::IMPORTFROMFILE)) {
578583
return false;
@@ -659,7 +664,7 @@ public static function getMenuContent(): array|false
659664
*
660665
* @return string
661666
*/
662-
public function getMainClass(): string
667+
public function getMainClass()
663668
{
664669
$class_ns = '\Glpi\Inventory\MainAsset\\';
665670
$main_class = $class_ns . $this->item::class;
@@ -832,7 +837,7 @@ final public function processInventoryData(): void
832837
*
833838
* @return void
834839
*/
835-
public function handleItem(): void
840+
public function handleItem()
836841
{
837842
if ($this->mainasset->checkConf($this->conf)) {
838843
//inject converted assets
@@ -851,7 +856,7 @@ public function handleItem(): void
851856
*
852857
* @return Agent
853858
*/
854-
public function getAgent(): Agent
859+
public function getAgent()
855860
{
856861
return $this->agent;
857862
}
@@ -884,7 +889,7 @@ protected function addBench($asset, $type, $start, $extra = null): void
884889
*
885890
* @return void
886891
*/
887-
public function printBenchResults(): void
892+
public function printBenchResults()
888893
{
889894
$output = '';
890895
foreach ($this->benchs as $asset => $types) {
@@ -941,7 +946,7 @@ public function printBenchResults(): void
941946
}
942947
}
943948

944-
public static function getIcon(): string
949+
public static function getIcon()
945950
{
946951
return "ti ti-cloud-download";
947952
}
@@ -951,7 +956,10 @@ public function getMetadata(): array
951956
return $this->metadata;
952957
}
953958

954-
public function getAssets(): array
959+
/**
960+
* @return array
961+
*/
962+
public function getAssets()
955963
{
956964
return $this->assets;
957965
}
@@ -966,7 +974,12 @@ public function getItem(): CommonDBTM
966974
return $this->item;
967975
}
968976

969-
public static function cronInfo(string $name): array
977+
/**
978+
* @param string $name
979+
*
980+
* @return array
981+
*/
982+
public static function cronInfo($name)
970983
{
971984
switch ($name) {
972985
case 'cleantemp':
@@ -985,7 +998,7 @@ public static function cronInfo(string $name): array
985998
*
986999
* @return int
9871000
**/
988-
public static function cronCleantemp(CronTask $task): int
1001+
public static function cronCleantemp($task)
9891002
{
9901003
$conf = new Conf();
9911004
$temp_files = glob(GLPI_INVENTORY_DIR . '/*.{' . implode(',', $conf->knownInventoryExtensions()) . '}', GLOB_BRACE);
@@ -1015,7 +1028,7 @@ public static function cronCleantemp(CronTask $task): int
10151028
*
10161029
* @return int
10171030
**/
1018-
public static function cronCleanorphans(CronTask $task): int
1031+
public static function cronCleanorphans($task)
10191032
{
10201033
global $DB;
10211034

@@ -1090,7 +1103,7 @@ public static function cronCleanorphans(CronTask $task): int
10901103
return 1;
10911104
}
10921105

1093-
public static function getTypeName(int $nb = 0): string
1106+
public static function getTypeName($nb = 0)
10941107
{
10951108
return __("Inventory");
10961109
}

0 commit comments

Comments
 (0)