Skip to content

Commit a567510

Browse files
authored
Add types doc to *Common* classes (#21981)
closes #21793
1 parent 369df6a commit a567510

12 files changed

+187
-55
lines changed

src/CommonDropdown.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,8 @@ public function isUsed()
597597
/**
598598
* Report if a dropdown have Child
599599
* Used to (dis)allow delete action
600+
*
601+
* @return bool
600602
**/
601603
public function haveChildren()
602604
{
@@ -609,6 +611,8 @@ public function haveChildren()
609611
* And propose a value to replace
610612
*
611613
* since 11.0.0 The `$target` parameter has been removed and its value is automatically computed.
614+
*
615+
* @return bool
612616
*/
613617
public function showDeleteConfirmForm()
614618
{
@@ -679,6 +683,8 @@ public function showDeleteConfirmForm()
679683
echo "</td></tr></table>\n";
680684
Html::closeForm();
681685
echo "</div>";
686+
687+
return true;
682688
}
683689

684690

@@ -920,8 +926,10 @@ public static function processMassiveActionsForOneItemtype(
920926
/**
921927
* Get links to Faq
922928
*
923-
* @param $withname boolean also display name ? (false by default)
924-
**/
929+
* @param bool $withname also display name ? (false by default)
930+
*
931+
* @return string
932+
*/
925933
public function getLinks($withname = false)
926934
{
927935
global $CFG_GLPI;

src/CommonITILActor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function getActors(int $items_id): array
109109
/**
110110
* @param int $items_id
111111
* @param string $email
112+
*
112113
* @return bool
113114
*/
114115
public function isAlternateEmailForITILObject($items_id, $email)

src/CommonITILCost.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public static function getIcon()
5757
return Infocom::getIcon();
5858
}
5959

60+
/**
61+
* @return class-string<CommonDBTM>
62+
*/
6063
public function getItilObjectItemType()
6164
{
6265
return str_replace('Cost', '', static::class);
@@ -360,6 +363,8 @@ public function initBasedOnPrevious(): void
360363
* Get total action time used on costs for an item
361364
*
362365
* @param integer $items_id ID of the item
366+
*
367+
* @return int
363368
**/
364369
public function getTotalActionTimeForItem($items_id)
365370
{
@@ -371,13 +376,15 @@ public function getTotalActionTimeForItem($items_id)
371376
'WHERE' => [static::$items_id => $items_id],
372377
])->current();
373378

374-
return $result['sumtime'];
379+
return (int) $result['sumtime'];
375380
}
376381

377382
/**
378383
* Get last datas for an item
379384
*
380385
* @param integer $items_id ID of the item
386+
*
387+
* @return array
381388
**/
382389
public function getLastCostForItem($items_id)
383390
{

src/CommonITILObject_CommonITILObject.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,13 @@ public static function countLinksByStatus(string $itemtype, int $items_id, array
591591
return ((int) $result['cpt']) + $count;
592592
}
593593

594+
/**
595+
* @param class-string<CommonDBTM> $itemtype
596+
* @param int $items_id
597+
* @param array $changes
598+
*
599+
* @return void
600+
*/
594601
public static function manageLinksOnChange($itemtype, $items_id, $changes): void
595602
{
596603
if ($itemtype === Ticket::class) {

src/CommonITILRecurrent.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,22 @@ abstract class CommonITILRecurrent extends CommonDropdown
6363

6464
/**
6565
* Concrete items to be instanciated
66+
*
67+
* @return class-string<CommonDBTM>
6668
*/
6769
abstract public static function getConcreteClass();
6870

6971
/**
7072
* Template class to use to create the concrete items
73+
*
74+
* @return class-string<CommonDBTM>
7175
*/
7276
abstract public static function getTemplateClass();
7377

7478
/**
7579
* Predefined field class to use to set the concrete items's data
80+
*
81+
* @return class-string<CommonDBTM>
7682
*/
7783
abstract public static function getPredefinedFieldsClass();
7884

@@ -566,6 +572,8 @@ public function handlePredefinedFields(
566572

567573
/**
568574
* Get all available types to which an ITIL object can be assigned
575+
*
576+
* @return class-string<CommonDBTM>[]
569577
**/
570578
public static function getAllTypesForHelpdesk()
571579
{

src/CommonITILSatisfaction.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ public function canUpdateItem(): bool
134134
* form for satisfaction
135135
*
136136
* @param CommonITILObject $item The item this satisfaction is for
137-
**/
137+
* @param bool $add_form_header
138+
*
139+
* @return void
140+
*/
138141
public function showSatisactionForm($item, bool $add_form_header = true)
139142
{
140143
$options = [];
@@ -223,6 +226,11 @@ public function post_addItem()
223226
}
224227
}
225228

229+
/**
230+
* @param bool $history
231+
*
232+
* @return void
233+
*/
226234
public function post_UpdateItem($history = true)
227235
{
228236
global $CFG_GLPI;
@@ -245,7 +253,10 @@ public function post_UpdateItem($history = true)
245253
* display satisfaction value
246254
*
247255
* @param int|float $value Between 0 and 10
248-
**/
256+
* @param int $entities_id
257+
*
258+
* @return string
259+
*/
249260
public static function displaySatisfaction($value, $entities_id)
250261
{
251262
if (!is_numeric($value)) {
@@ -286,7 +297,9 @@ public static function displaySatisfaction($value, $entities_id)
286297
* Get name of inquest type
287298
*
288299
* @param int $value Survey type ID
289-
**/
300+
*
301+
* @return string
302+
*/
290303
public static function getTypeInquestName($value)
291304
{
292305

@@ -299,7 +312,7 @@ public static function getTypeInquestName($value)
299312

300313
default:
301314
// Get value if not defined
302-
return $value;
315+
return (string) $value;
303316
}
304317
}
305318

@@ -348,6 +361,9 @@ public static function getFormURLWithID($id = 0, $full = true)
348361
return $item::getFormURLWithID($satisfaction->fields[$item::getForeignKeyField()]) . '&forcetab=' . $item::class . '$3';
349362
}
350363

364+
/**
365+
* @return array
366+
*/
351367
public static function rawSearchOptionsToAdd()
352368
{
353369
global $DB;

src/CommonITILTask.php

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,18 @@ public static function canUpdate(): bool
112112
));
113113
}
114114

115-
115+
/**
116+
* @return bool|int
117+
*/
116118
public function canViewPrivates()
117119
{
118120
return Session::haveRight(self::$rightname, self::SEEPRIVATE);
119121
}
120122

121123

124+
/**
125+
* @return bool
126+
*/
122127
public function canEditAll()
123128
{
124129
return Session::haveRightsOr(self::$rightname, [CREATE, DELETE, PURGE, self::UPDATEALL]);
@@ -998,12 +1003,12 @@ public function rawSearchOptions()
9981003
}
9991004

10001005
/**
1001-
* @since 0.85
1002-
**/
1006+
* @param ?class-string<CommonDBTM> $itemtype
1007+
*
1008+
* @return array
1009+
*/
10031010
public static function rawSearchOptionsToAdd($itemtype = null)
10041011
{
1005-
global $DB;
1006-
10071012
$task = new static();
10081013
$tab = [];
10091014
$name = _n('Task', 'Tasks', Session::getPluralNumber());
@@ -1271,12 +1276,12 @@ public static function rawSearchOptionsToAdd($itemtype = null)
12711276
}
12721277

12731278
/**
1274-
* Current dates are valid ? begin before end
1279+
* Current dates are valid? begin before end
12751280
*
1276-
* @param $input
1281+
* @param array $input
12771282
*
1278-
*@return boolean
1279-
**/
1283+
* @return bool
1284+
*/
12801285
public function test_valid_date($input)
12811286
{
12821287

@@ -1669,10 +1674,11 @@ public static function genericDisplayPlanningItem($itemtype, array $val, $who, $
16691674

16701675
/** form for Task
16711676
*
1672-
* @param $ID Integer : Id of the task
1673-
* @param $options array
1674-
* - parent Object : the object
1675-
**/
1677+
* @param int $ID Id of the task
1678+
* @param array $options [parent Object : the object]
1679+
*
1680+
* @return true
1681+
*/
16761682
public function showForm($ID, array $options = [])
16771683
{
16781684
TemplateRenderer::getInstance()->display('components/itilobject/timeline/form_task.html.twig', [
@@ -1687,6 +1693,8 @@ public function showForm($ID, array $options = [])
16871693

16881694
/**
16891695
* Form for Ticket or Problem Task on Massive action
1696+
*
1697+
* @return void
16901698
*/
16911699
public function showMassiveActionAddTaskForm()
16921700
{
@@ -1714,6 +1722,11 @@ public function showMassiveActionAddTaskForm()
17141722
*
17151723
* @since 9.2
17161724
*
1725+
* @param string $status
1726+
* @param bool $showgrouptickets
1727+
* @param ?int $start
1728+
* @param ?int $limit
1729+
*
17171730
* @return DBmysqlIterator
17181731
*/
17191732
public static function getTaskList($status, $showgrouptickets, $start = null, $limit = null)

0 commit comments

Comments
 (0)