Skip to content

Commit c409b13

Browse files
authored
Add types on assets (#21860)
1 parent 9cff5e0 commit c409b13

38 files changed

+363
-82
lines changed

src/CleanSoftwareCron.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ public static function getParameterDescription(): string
6666
return __('Max items to handle in one execution');
6767
}
6868

69+
/**
70+
* @param string $name
71+
*
72+
* @return array
73+
*/
6974
public static function cronInfo($name)
7075
{
7176
return [
@@ -77,7 +82,7 @@ public static function cronInfo($name)
7782
/**
7883
* Clean unused software and software versions
7984
*
80-
* @param int $max Max items to handle
85+
* @param ?int $max Max items to handle
8186
* @return int Number of deleted items
8287
*/
8388
public static function run(?int $max): int
@@ -107,6 +112,8 @@ public static function run(?int $max): int
107112
* Run from cronTask
108113
*
109114
* @param CronTask $task
115+
*
116+
* @return int
110117
*/
111118
public static function cronCleanSoftware(CronTask $task)
112119
{

src/CommonDropdown.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ abstract class CommonDropdown extends CommonDBTM
6262
public $display_dropdowntitle = true;
6363

6464
/**
65-
* This dropdown can be translated
65+
* Flag to determine whether dropdown can be translated.
66+
*
6667
* @var bool
6768
*/
6869
public $can_be_translated = true;

src/Computer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ class Computer extends CommonDBTM implements AssignableItemInterface, DCBreadcru
6565
'Item_OperatingSystem',
6666
];
6767
// Specific ones
68-
///Device container - format $device = array(ID,"device type","ID in device table","specificity value")
68+
/**
69+
* Device container - format $device = array(ID,"device type","ID in device table","specificity value")
70+
*
71+
* @var array
72+
*/
6973
public $devices = [];
7074

7175
public static $rightname = 'computer';

src/Consumable.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,11 @@ public static function displayConsumableList(ConsumableItem $parent): void
571571
]);
572572
}
573573

574+
/**
575+
* @param User $user
576+
*
577+
* @return void
578+
*/
574579
public static function showForUser(User $user)
575580
{
576581
global $DB;

src/ConsumableItem.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ public function rawSearchOptions()
316316
return $tab;
317317
}
318318

319+
/**
320+
* @param string $name
321+
*
322+
* @return array
323+
*/
319324
public static function cronInfo($name)
320325
{
321326
return ['description' => __('Send alarms on consumables')];
@@ -457,6 +462,9 @@ public static function cronConsumable(?CronTask $task = null)
457462
return $cron_status;
458463
}
459464

465+
/**
466+
* @return array
467+
*/
460468
public function getEvents()
461469
{
462470
return ['alert' => __('Send alarms on consumables')];

src/Glpi/Asset/Asset.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ public function rawSearchOptions()
352352
return $search_options;
353353
}
354354

355+
/**
356+
* @return string[]
357+
*/
355358
public function getUnallowedFieldsForUnicity()
356359
{
357360
$not_allowed = parent::getUnallowedFieldsForUnicity();

src/Glpi/Asset/Asset_PeripheralAsset.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,12 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
746746
return false;
747747
}
748748

749+
/**
750+
* @param CommonDBTM $item
751+
* @param array $entities
752+
*
753+
* @return bool
754+
*/
749755
public static function canUnrecursSpecif(CommonDBTM $item, $entities)
750756
{
751757
global $DB;
@@ -838,6 +844,11 @@ public static function getTypeName($nb = 0)
838844
return _n('Connection', 'Connections', $nb);
839845
}
840846

847+
/**
848+
* @param ?class-string<CommonDBTM> $itemtype
849+
*
850+
* @return array
851+
*/
841852
public static function rawSearchOptionsToAdd($itemtype = null)
842853
{
843854
global $CFG_GLPI;

src/HTMLTableBase.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,11 @@ public function getSuperHeaderByName($name)
157157
}
158158

159159
/**
160-
* @param $name
161-
* @param $sub_name (default NULL)
162-
**/
160+
* @param string $name
161+
* @param ?string $sub_name (default NULL)
162+
*
163+
* @throws HTMLTableUnknownHeader
164+
*/
163165
public function getHeaderByName($name, $sub_name = null)
164166
{
165167
if (is_string($sub_name)) {

src/IPAddress_IPNetwork.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ class IPAddress_IPNetwork extends CommonDBRelation
5454
* Update IPNetwork's dependency
5555
*
5656
* @param $network IPNetwork object
57-
**/
57+
*
58+
* @return void
59+
*/
5860
public static function linkIPAddressFromIPNetwork(IPNetwork $network)
5961
{
6062
global $DB;
@@ -91,7 +93,9 @@ public static function linkIPAddressFromIPNetwork(IPNetwork $network)
9193

9294
/**
9395
* @param $ipaddress IPAddress object
94-
**/
96+
*
97+
* @return void
98+
*/
9599
public static function addIPAddress(IPAddress $ipaddress)
96100
{
97101

src/IPNetwork.php

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ public function rawSearchOptions()
142142
}
143143

144144

145+
/**
146+
* @return false|IPAddress
147+
*/
145148
public function getAddress()
146149
{
147150

@@ -155,6 +158,9 @@ public function getAddress()
155158
}
156159

157160

161+
/**
162+
* @return false|IPNetmask
163+
*/
158164
public function getNetmask()
159165
{
160166

@@ -168,6 +174,9 @@ public function getNetmask()
168174
}
169175

170176

177+
/**
178+
* @return false|IPAddress
179+
*/
171180
public function getGateway()
172181
{
173182

@@ -264,8 +273,10 @@ public function getNewAncestor()
264273

265274

266275
/**
267-
* @param $input
268-
**/
276+
* @param array $input
277+
*
278+
* @return array
279+
*/
269280
public function prepareInput($input)
270281
{
271282

@@ -907,11 +918,15 @@ public static function checkNetworkRelativity(
907918
* Compute the first and the last address of $this
908919
* \see computeNetworkRangeFromAdressAndNetmask()
909920
*
910-
* @param $start
911-
* @param $end (default NULL)
912-
* @param $excludeBroadcastAndNetwork Don't provide extremties addresses
921+
* @param IPAddress|array|null $start
922+
* @param IPAddress|array|null $end (default NULL)
923+
* @param string $excludeBroadcastAndNetwork Don't provide extremties addresses
913924
* ($this->fields['addressable'] by default)
914925
* (default '')
926+
*
927+
* @return void
928+
*
929+
* @TODO Deprecate the `$excludeBroadcastAndNetwork`, it is never used.
915930
**/
916931
public function computeNetworkRange(&$start, &$end = null, $excludeBroadcastAndNetwork = '')
917932
{
@@ -936,18 +951,20 @@ public function computeNetworkRange(&$start, &$end = null, $excludeBroadcastAndN
936951

937952
/**
938953
* \brief Compute the first and the last address of a network.
939-
* That is usefull, for instance, to compute the "real" network address (the first address)
954+
* That is useful, for instance, to compute the "real" network address (the first address)
940955
* or the broadcast address of the network
941956
*
942-
* @param $address (see \ref parameterType) the address of the network
943-
* @param $netmask (see \ref parameterType) its netmask
944-
* @param $firstAddress (see \ref parameterType - in/out)
945-
* the first address (ie real address of the network)
946-
* @param $lastAddress (see \ref parameterType - in/out)
947-
* the lastAddress of the network
948-
* (ie. : the broadcast address) (default NULL)
949-
* @param $excludeBroadcastAndNetwork boolean exclude broadcast and network address from the
950-
* result (false by default)
957+
* @param IPAddress|array $address (see \ref parameterType) the address of the network
958+
* @param IPNetmask|array $netmask (see \ref parameterType) its netmask
959+
* @param IPAddress|array|null $firstAddress (see \ref parameterType - in/out)
960+
* the first address (ie real address of the network)
961+
* @param IPAddress|array|null $lastAddress (see \ref parameterType - in/out)
962+
* the lastAddress of the network
963+
* (ie. : the broadcast address) (default NULL)
964+
* @param bool $excludeBroadcastAndNetwork exclude broadcast and network address from the
965+
* result (false by default)
966+
*
967+
* @return void
951968
**/
952969
public static function computeNetworkRangeFromAdressAndNetmask(
953970
$address,
@@ -989,14 +1006,16 @@ public static function computeNetworkRangeFromAdressAndNetmask(
9891006

9901007

9911008
/**
1009+
* @param class-string<CommonDBTM> $itemtype
1010+
* @param HTMLTableBase $base
1011+
* @param HTMLTableSuperHeader|null $super
1012+
* @param HTMLTableHeader|null $father
1013+
* @param array $options
1014+
* @throws Exception
9921015
* @since 0.84
9931016
*
994-
* @param $itemtype
995-
* @param $base HTMLTableBase object
996-
* @param $super HTMLTableSuperHeader object (default NULL)
997-
* @param $father HTMLTableHeader object (default NULL)
998-
* @param $options array
999-
**/
1017+
* @return void
1018+
*/
10001019
public static function getHTMLTableHeader(
10011020
$itemtype,
10021021
HTMLTableBase $base,
@@ -1021,13 +1040,15 @@ public static function getHTMLTableHeader(
10211040

10221041

10231042
/**
1024-
* @since 0.84
1043+
* @param HTMLTableRow|null $row
1044+
* @param CommonDBTM|null $item
1045+
* @param HTMLTableCell|null $father
1046+
* @param array $options
1047+
* @return void
1048+
* @throws HTMLTableUnknownHeader
10251049
*
1026-
* @param $row HTMLTableRow object (default NULL)
1027-
* @param $item CommonDBTM object (default NULL)
1028-
* @param $father HTMLTableCell object (default NULL)
1029-
* @param $options array
1030-
**/
1050+
* @return void
1051+
*/
10311052
public static function getHTMLTableCellsForItem(
10321053
?HTMLTableRow $row = null,
10331054
?CommonDBTM $item = null,
@@ -1095,9 +1116,12 @@ public static function getHTMLTableCellsForItem(
10951116
/**
10961117
* Show all available IPNetwork for a given entity
10971118
*
1098-
* @param $entities_id entity of the IPNetworks (-1 for all entities)
1099-
* (default -1)
1100-
**/
1119+
* @param int $entities_id entity of the IPNetworks (-1 for all entities)
1120+
* (default -1)
1121+
* @param int $value
1122+
*
1123+
* @return void
1124+
*/
11011125
public static function showIPNetworkProperties($entities_id = -1, $value = 0)
11021126
{
11031127
global $CFG_GLPI;

0 commit comments

Comments
 (0)