Skip to content

Commit a58a2a8

Browse files
cconard96trasher
authored andcommitted
replace non-display uses of CommonDBTM::getField()
1 parent 53efe30 commit a58a2a8

80 files changed

Lines changed: 416 additions & 466 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.phpstan-baseline.php

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,7 +2896,7 @@
28962896
$ignoreErrors[] = [
28972897
'message' => '#^Cannot call method getField\\(\\) on CommonDBTM\\|false\\.$#',
28982898
'identifier' => 'method.nonObject',
2899-
'count' => 2,
2899+
'count' => 1,
29002900
'path' => __DIR__ . '/src/CommonDBTM.php',
29012901
];
29022902
$ignoreErrors[] = [
@@ -2912,7 +2912,7 @@
29122912
'path' => __DIR__ . '/src/CommonDBTM.php',
29132913
];
29142914
$ignoreErrors[] = [
2915-
'message' => '#^Cannot call method isField\\(\\) on CommonDBTM\\|false\\.$#',
2915+
'message' => '#^Cannot call method isDeleted\\(\\) on CommonDBTM\\|false\\.$#',
29162916
'identifier' => 'method.nonObject',
29172917
'count' => 1,
29182918
'path' => __DIR__ . '/src/CommonDBTM.php',
@@ -4184,25 +4184,25 @@
41844184
'path' => __DIR__ . '/src/Computer.php',
41854185
];
41864186
$ignoreErrors[] = [
4187-
'message' => '#^Cannot call method getField\\(\\) on CommonDBTM\\|false\\.$#',
4187+
'message' => '#^Cannot call method getFromDB\\(\\) on CommonDBTM\\|false\\.$#',
41884188
'identifier' => 'method.nonObject',
41894189
'count' => 1,
41904190
'path' => __DIR__ . '/src/Computer.php',
41914191
];
41924192
$ignoreErrors[] = [
4193-
'message' => '#^Cannot call method getFromDB\\(\\) on CommonDBTM\\|false\\.$#',
4193+
'message' => '#^Cannot call method getID\\(\\) on CommonDBTM\\|false\\.$#',
41944194
'identifier' => 'method.nonObject',
41954195
'count' => 1,
41964196
'path' => __DIR__ . '/src/Computer.php',
41974197
];
41984198
$ignoreErrors[] = [
4199-
'message' => '#^Cannot call method getID\\(\\) on CommonDBTM\\|false\\.$#',
4199+
'message' => '#^Cannot call method getLink\\(\\) on Agent\\|null\\.$#',
42004200
'identifier' => 'method.nonObject',
42014201
'count' => 1,
42024202
'path' => __DIR__ . '/src/Computer.php',
42034203
];
42044204
$ignoreErrors[] = [
4205-
'message' => '#^Cannot call method getLink\\(\\) on Agent\\|null\\.$#',
4205+
'message' => '#^Cannot call method isGlobal\\(\\) on CommonDBTM\\|false\\.$#',
42064206
'identifier' => 'method.nonObject',
42074207
'count' => 1,
42084208
'path' => __DIR__ . '/src/Computer.php',
@@ -13988,8 +13988,8 @@
1398813988
'path' => __DIR__ . '/src/ITILFollowup.php',
1398913989
];
1399013990
$ignoreErrors[] = [
13991-
'message' => '#^Cannot call method getForeignKeyField\\(\\) on CommonDBTM\\|false\\|null\\.$#',
13992-
'identifier' => 'method.nonObject',
13991+
'message' => '#^Cannot call static method getForeignKeyField\\(\\) on CommonDBTM\\|false\\|null\\.$#',
13992+
'identifier' => 'staticMethod.nonObject',
1399313993
'count' => 1,
1399413994
'path' => __DIR__ . '/src/ITILFollowup.php',
1399513995
];
@@ -16219,12 +16219,6 @@
1621916219
'count' => 1,
1622016220
'path' => __DIR__ . '/src/NotificationTargetCommonITILObject.php',
1622116221
];
16222-
$ignoreErrors[] = [
16223-
'message' => '#^Cannot call method getField\\(\\) on \\(T of CommonITILObject\\)\\|null\\.$#',
16224-
'identifier' => 'method.nonObject',
16225-
'count' => 1,
16226-
'path' => __DIR__ . '/src/NotificationTargetCommonITILObject.php',
16227-
];
1622816222
$ignoreErrors[] = [
1622916223
'message' => '#^Cannot call method getField\\(\\) on CommonDBTM\\|false\\.$#',
1623016224
'identifier' => 'method.nonObject',
@@ -16252,7 +16246,7 @@
1625216246
$ignoreErrors[] = [
1625316247
'message' => '#^Cannot call method getID\\(\\) on \\(T of CommonITILObject\\)\\|null\\.$#',
1625416248
'identifier' => 'method.nonObject',
16255-
'count' => 1,
16249+
'count' => 2,
1625616250
'path' => __DIR__ . '/src/NotificationTargetCommonITILObject.php',
1625716251
];
1625816252
$ignoreErrors[] = [
@@ -16606,19 +16600,19 @@
1660616600
$ignoreErrors[] = [
1660716601
'message' => '#^Cannot access property \\$fields on Project\\|null\\.$#',
1660816602
'identifier' => 'property.nonObject',
16609-
'count' => 5,
16603+
'count' => 23,
1661016604
'path' => __DIR__ . '/src/NotificationTargetProject.php',
1661116605
];
1661216606
$ignoreErrors[] = [
1661316607
'message' => '#^Cannot call method getField\\(\\) on Project\\|null\\.$#',
1661416608
'identifier' => 'method.nonObject',
16615-
'count' => 26,
16609+
'count' => 4,
1661616610
'path' => __DIR__ . '/src/NotificationTargetProject.php',
1661716611
];
1661816612
$ignoreErrors[] = [
1661916613
'message' => '#^Cannot call method getID\\(\\) on Project\\|null\\.$#',
1662016614
'identifier' => 'method.nonObject',
16621-
'count' => 2,
16615+
'count' => 6,
1662216616
'path' => __DIR__ . '/src/NotificationTargetProject.php',
1662316617
];
1662416618
$ignoreErrors[] = [
@@ -16660,19 +16654,19 @@
1666016654
$ignoreErrors[] = [
1666116655
'message' => '#^Cannot access property \\$fields on ProjectTask\\|null\\.$#',
1666216656
'identifier' => 'property.nonObject',
16663-
'count' => 6,
16657+
'count' => 26,
1666416658
'path' => __DIR__ . '/src/NotificationTargetProjectTask.php',
1666516659
];
1666616660
$ignoreErrors[] = [
1666716661
'message' => '#^Cannot call method getField\\(\\) on ProjectTask\\|null\\.$#',
1666816662
'identifier' => 'method.nonObject',
16669-
'count' => 26,
16663+
'count' => 3,
1667016664
'path' => __DIR__ . '/src/NotificationTargetProjectTask.php',
1667116665
];
1667216666
$ignoreErrors[] = [
1667316667
'message' => '#^Cannot call method getID\\(\\) on ProjectTask\\|null\\.$#',
1667416668
'identifier' => 'method.nonObject',
16675-
'count' => 1,
16669+
'count' => 4,
1667616670
'path' => __DIR__ . '/src/NotificationTargetProjectTask.php',
1667716671
];
1667816672
$ignoreErrors[] = [
@@ -16699,6 +16693,12 @@
1669916693
'count' => 1,
1670016694
'path' => __DIR__ . '/src/NotificationTargetReservation.php',
1670116695
];
16696+
$ignoreErrors[] = [
16697+
'message' => '#^Cannot access property \\$fields on Reservation\\|null\\.$#',
16698+
'identifier' => 'property.nonObject',
16699+
'count' => 4,
16700+
'path' => __DIR__ . '/src/NotificationTargetReservation.php',
16701+
];
1670216702
$ignoreErrors[] = [
1670316703
'message' => '#^Cannot assign new offset to array\\<array\\<string, mixed\\>\\|string\\>\\|string\\.$#',
1670416704
'identifier' => 'offsetAssign.dimType',
@@ -16708,7 +16708,13 @@
1670816708
$ignoreErrors[] = [
1670916709
'message' => '#^Cannot call method getField\\(\\) on Reservation\\|null\\.$#',
1671016710
'identifier' => 'method.nonObject',
16711-
'count' => 6,
16711+
'count' => 1,
16712+
'path' => __DIR__ . '/src/NotificationTargetReservation.php',
16713+
];
16714+
$ignoreErrors[] = [
16715+
'message' => '#^Cannot call method getID\\(\\) on Reservation\\|null\\.$#',
16716+
'identifier' => 'method.nonObject',
16717+
'count' => 1,
1671216718
'path' => __DIR__ . '/src/NotificationTargetReservation.php',
1671316719
];
1671416720
$ignoreErrors[] = [
@@ -16730,8 +16736,8 @@
1673016736
'path' => __DIR__ . '/src/NotificationTargetSavedSearch_Alert.php',
1673116737
];
1673216738
$ignoreErrors[] = [
16733-
'message' => '#^Cannot call method getField\\(\\) on SavedSearch_Alert\\|null\\.$#',
16734-
'identifier' => 'method.nonObject',
16739+
'message' => '#^Cannot access property \\$fields on SavedSearch_Alert\\|null\\.$#',
16740+
'identifier' => 'property.nonObject',
1673516741
'count' => 1,
1673616742
'path' => __DIR__ . '/src/NotificationTargetSavedSearch_Alert.php',
1673716743
];
@@ -16760,7 +16766,7 @@
1676016766
'path' => __DIR__ . '/src/NotificationTargetSoftwareLicense.php',
1676116767
];
1676216768
$ignoreErrors[] = [
16763-
'message' => '#^Cannot call method getField\\(\\) on Ticket\\|null\\.$#',
16769+
'message' => '#^Cannot call method getID\\(\\) on Ticket\\|null\\.$#',
1676416770
'identifier' => 'method.nonObject',
1676516771
'count' => 1,
1676616772
'path' => __DIR__ . '/src/NotificationTargetTicket.php',
@@ -16774,7 +16780,7 @@
1677416780
$ignoreErrors[] = [
1677516781
'message' => '#^Cannot access property \\$fields on User\\|null\\.$#',
1677616782
'identifier' => 'property.nonObject',
16777-
'count' => 2,
16783+
'count' => 3,
1677816784
'path' => __DIR__ . '/src/NotificationTargetUser.php',
1677916785
];
1678016786
$ignoreErrors[] = [
@@ -16786,7 +16792,7 @@
1678616792
$ignoreErrors[] = [
1678716793
'message' => '#^Cannot call method getField\\(\\) on User\\|null\\.$#',
1678816794
'identifier' => 'method.nonObject',
16789-
'count' => 4,
16795+
'count' => 3,
1679016796
'path' => __DIR__ . '/src/NotificationTargetUser.php',
1679116797
];
1679216798
$ignoreErrors[] = [
@@ -16867,12 +16873,6 @@
1686716873
'count' => 1,
1686816874
'path' => __DIR__ . '/src/NotificationTemplate.php',
1686916875
];
16870-
$ignoreErrors[] = [
16871-
'message' => '#^Parameter \\#1 \\$object_or_class of function method_exists expects object\\|string, CommonGLPI\\|null given\\.$#',
16872-
'identifier' => 'argument.type',
16873-
'count' => 1,
16874-
'path' => __DIR__ . '/src/NotificationTemplate.php',
16875-
];
1687616876
$ignoreErrors[] = [
1687716877
'message' => '#^Parameter \\#1 \\$object_or_class of function property_exists expects object\\|string, CommonGLPI\\|null given\\.$#',
1687816878
'identifier' => 'argument.type',
@@ -19093,6 +19093,12 @@
1909319093
'count' => 1,
1909419094
'path' => __DIR__ . '/src/SavedSearch.php',
1909519095
];
19096+
$ignoreErrors[] = [
19097+
'message' => '#^Parameter \\#1 \\$itemtype of method Search\\:\\:prepareDatasForSearch\\(\\) expects class\\-string\\<CommonDBTM\\>, class\\-string given\\.$#',
19098+
'identifier' => 'argument.type',
19099+
'count' => 1,
19100+
'path' => __DIR__ . '/src/SavedSearch.php',
19101+
];
1909619102
$ignoreErrors[] = [
1909719103
'message' => '#^Offset \'savedsearches_id\' might not exist on array\\<string, mixed\\>\\|null\\.$#',
1909819104
'identifier' => 'offsetAccess.notFound',
@@ -19538,8 +19544,8 @@
1953819544
'path' => __DIR__ . '/src/Telemetry.php',
1953919545
];
1954019546
$ignoreErrors[] = [
19541-
'message' => '#^Cannot call method getField\\(\\) on CommonDBTM\\|false\\.$#',
19542-
'identifier' => 'method.nonObject',
19547+
'message' => '#^Cannot access property \\$fields on CommonDBTM\\|false\\.$#',
19548+
'identifier' => 'property.nonObject',
1954319549
'count' => 1,
1954419550
'path' => __DIR__ . '/src/Ticket.php',
1954519551
];

ajax/commonitilsatisfaction.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@
4949
if (!$ent->canViewItem()) {
5050
throw new AccessDeniedHttpException();
5151
}
52-
$inquest_delay = $ent->getfield('inquest_delay' . $config_suffix);
53-
$inquest_rate = $ent->getfield('inquest_rate' . $config_suffix);
54-
$inquest_duration = $ent->getfield('inquest_duration' . $config_suffix);
55-
$inquest_max_rate = $ent->getfield('inquest_max_rate' . $config_suffix);
56-
$inquest_default_rate = $ent->getfield('inquest_default_rate' . $config_suffix);
57-
$inquest_mandatory_comment = $ent->getfield('inquest_mandatory_comment' . $config_suffix);
58-
$max_closedate = $ent->getfield('max_closedate' . $config_suffix);
52+
$inquest_delay = $ent->fields['inquest_delay' . $config_suffix];
53+
$inquest_rate = $ent->fields['inquest_rate' . $config_suffix];
54+
$inquest_duration = $ent->fields['inquest_duration' . $config_suffix];
55+
$inquest_max_rate = $ent->fields['inquest_max_rate' . $config_suffix];
56+
$inquest_default_rate = $ent->fields['inquest_default_rate' . $config_suffix];
57+
$inquest_mandatory_comment = $ent->fields['inquest_mandatory_comment' . $config_suffix];
58+
$max_closedate = $ent->fields['max_closedate' . $config_suffix];
5959
} else {
6060
$inquest_delay = -1;
6161
$inquest_rate = -1;

ajax/dropdownTicketCategories.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@
5050
switch ($_POST['type']) {
5151
case Ticket::INCIDENT_TYPE:
5252
$condition['is_incident'] = 1;
53-
if ($currentcateg->getField('is_incident') == 1) {
53+
if ($currentcateg->fields['is_incident'] == 1) {
5454
$opt['value'] = $_POST['value'];
5555
}
5656
break;
5757

5858
case Ticket::DEMAND_TYPE:
5959
$condition['is_request'] = 1;
60-
if ($currentcateg->getField('is_request') == 1) {
60+
if ($currentcateg->fields['is_request'] == 1) {
6161
$opt['value'] = $_POST['value'];
6262
}
6363
break;

front/changesatisfaction.form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
$inquest->update($_POST);
4646

4747
Event::log(
48-
$inquest->getField('changes_id'),
48+
$inquest->fields['changes_id'],
4949
"change",
5050
4,
5151
"tracking",

front/commonitiltask.form.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
$itemtype = $track::class;
6161
$fk = $track::getForeignKeyField();
6262

63-
$track->getFromDB($task->getField($fk));
64-
6563
$redirect = null;
6664
$handled = false;
6765

@@ -70,60 +68,60 @@
7068
$task->add($_POST);
7169

7270
Event::log(
73-
$task->getField($fk),
71+
$task->fields[$fk],
7472
strtolower($itemtype),
7573
4,
7674
"tracking",
7775
//TRANS: %s is the user login
7876
sprintf(__('%s adds a task'), $_SESSION["glpiname"])
7977
);
80-
$redirect = $itemtype::getFormURLWithID($task->getField($fk));
78+
$redirect = $itemtype::getFormURLWithID($task->fields[$fk]);
8179
$handled = true;
8280
} elseif (isset($_POST["purge"])) {
8381
$task->check($_POST['id'], PURGE);
8482
$task->delete($_POST, true);
8583

8684
Event::log(
87-
$task->getField($fk),
85+
$task->fields[$fk],
8886
strtolower($itemtype),
8987
4,
9088
"tracking",
9189
//TRANS: %s is the user login
9290
sprintf(__('%s purges a task'), $_SESSION["glpiname"])
9391
);
94-
Html::redirect($itemtype::getFormURLWithID($task->getField($fk)));
92+
Html::redirect($itemtype::getFormURLWithID($task->fields[$fk]));
9593
} elseif (isset($_POST["update"])) {
9694
$task->check($_POST["id"], UPDATE);
9795
$task->update($_POST);
9896

9997
Event::log(
100-
$task->getField($fk),
98+
$task->fields[$fk],
10199
strtolower($itemtype),
102100
4,
103101
"tracking",
104102
//TRANS: %s is the user login
105103
sprintf(__('%s updates a task'), $_SESSION["glpiname"])
106104
);
107-
$redirect = $itemtype::getFormURLWithID($task->getField($fk));
105+
$redirect = $itemtype::getFormURLWithID($task->fields[$fk]);
108106
$handled = true;
109107
} elseif (isset($_POST["unplan"])) {
110108
$task->check($_POST["id"], UPDATE);
111109
$task->unplan();
112110

113111
Event::log(
114-
$task->getField($fk),
112+
$task->fields[$fk],
115113
strtolower($itemtype),
116114
4,
117115
"tracking",
118116
//TRANS: %s is the user login
119117
sprintf(__('%s unplans a task'), $_SESSION["glpiname"])
120118
);
121-
$redirect = $itemtype::getFormURLWithID($task->getField($fk));
119+
$redirect = $itemtype::getFormURLWithID($task->fields[$fk]);
122120
$handled = true;
123121
}
124122

125123
if ($handled) {
126-
if ($track->can($task->getField($fk), READ)) {
124+
if ($track->can($task->fields[$fk], READ)) {
127125
$toadd = '';
128126
// Copy followup to KB redirect to KB
129127
if (isset($_POST['_task_to_kb']) && $_POST['_task_to_kb']) {

front/commonitilvalidation.form.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
$_POST['items_id_target'] = $target;
8282
$validation->add($_POST);
8383
Event::log(
84-
$validation->getField($fk),
84+
$validation->fields[$fk],
8585
strtolower($itemtype),
8686
4,
8787
"tracking",
@@ -95,7 +95,7 @@
9595
$validation->check($_POST['id'], UPDATE);
9696
$validation->update($_POST);
9797
Event::log(
98-
$validation->getField($fk),
98+
$validation->fields[$fk],
9999
strtolower($itemtype),
100100
4,
101101
"tracking",
@@ -108,7 +108,7 @@
108108
$validation->delete($_POST, true);
109109

110110
Event::log(
111-
$validation->getField($fk),
111+
$validation->fields[$fk],
112112
strtolower($itemtype),
113113
4,
114114
"tracking",

0 commit comments

Comments
 (0)