Skip to content

Commit

Permalink
feat: prepare compatibility with PHP 8.2 (#2966)
Browse files Browse the repository at this point in the history
  • Loading branch information
btry authored Sep 9, 2022
1 parent 48dda4f commit 4bb7f3c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
12 changes: 6 additions & 6 deletions inc/abstractitiltarget.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,7 @@ public function cleanActors(array $data): array {
if (is_array($data["$actorType"])) {
if (count($data["$actorType"]) < 1) {
unset($data["$actorType"]);
unset($data["${actorType}_notif"]);
unset($data["{$actorType}_notif"]);
} else {
$cleaned = [];
$cleaned_notif = [];
Expand All @@ -2186,17 +2186,17 @@ public function cleanActors(array $data): array {
continue;
}
$cleaned[] = $actor;
$cleaned_notif['use_notification'][] = $data["${actorType}_notif"]['use_notification'][$key];
$cleaned_notif['alternative_email'][] = $data["${actorType}_notif"]['alternative_email'][$key];
$cleaned_notif['use_notification'][] = $data["{$actorType}_notif"]['use_notification'][$key];
$cleaned_notif['alternative_email'][] = $data["{$actorType}_notif"]['alternative_email'][$key];
}
$data["$actorType"] = $cleaned;
$data["${actorType}_notif"] = $cleaned_notif;
$data["{$actorType}_notif"] = $cleaned_notif;
}
} else {
if ($data["$actorType"] == 0) {
if (isset($data["${actorType}_notif"]) && count($data["${actorType}_notif"]) < 1) {
if (isset($data["{$actorType}_notif"]) && count($data["{$actorType}_notif"]) < 1) {
unset($data["$actorType"]);
unset($data["${actorType}_notif"]);
unset($data["{$actorType}_notif"]);
}
}
}
Expand Down
22 changes: 11 additions & 11 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ protected function showMyLastForms() : void {
echo '<div class="card-body">';
echo '<ul class="list-group">';
foreach ($search['data']['rows'] as $formAnswer) {
switch ($formAnswer['raw']["${rawKeyBase}_8"]) {
switch ($formAnswer['raw']["{$rawKeyBase}_8"]) {
case PluginFormcreatorFormAnswer::STATUS_WAITING:
$status = CommonITILObject::WAITING;
break;
Expand All @@ -933,12 +933,12 @@ protected function showMyLastForms() : void {
$status = CommonITILObject::ACCEPTED;
break;
default:
$status = $formAnswer['raw']["${rawKeyBase}_8"];
$status = $formAnswer['raw']["{$rawKeyBase}_8"];
}
$status = CommonITILObject::getStatusClass($status);
echo '<li data-itemtype="PluginFormcreatorFormanswer" data-id="' . $formAnswer['raw']["${rawKeyBase}_2"] . '">';
echo '<i class="'.$status.'"></i><a href="formanswer.form.php?id='. $formAnswer['raw']["${rawKeyBase}_2"] .'">'. $formAnswer['raw']["${rawKeyBase}_1"] .'</a>';
echo '<span class="plugin_formcreator_date">'.Html::convDateTime($formAnswer['raw']["${rawKeyBase}_6"]).'</span>';
echo '<li data-itemtype="PluginFormcreatorFormanswer" data-id="' . $formAnswer['raw']["{$rawKeyBase}_2"] . '">';
echo '<i class="'.$status.'"></i><a href="formanswer.form.php?id='. $formAnswer['raw']["{$rawKeyBase}_2"] .'">'. $formAnswer['raw']["{$rawKeyBase}_1"] .'</a>';
echo '<span class="plugin_formcreator_date">'.Html::convDateTime($formAnswer['raw']["{$rawKeyBase}_6"]).'</span>';
echo '</li>';
}
echo '</ul>';
Expand Down Expand Up @@ -990,7 +990,7 @@ protected function showMyLastForms() : void {
echo '<div class="card-body">';
echo '<ul class="list-group">';
foreach ($search['data']['rows'] as $formAnswer) {
switch ($formAnswer['raw']["${rawKeyBase}_8"]) {
switch ($formAnswer['raw']["{$rawKeyBase}_8"]) {
case PluginFormcreatorFormAnswer::STATUS_WAITING:
$status = CommonITILObject::WAITING;
break;
Expand All @@ -1001,12 +1001,12 @@ protected function showMyLastForms() : void {
$status = CommonITILObject::ACCEPTED;
break;
default:
$status = $formAnswer['raw']["${rawKeyBase}_8"];
$status = $formAnswer['raw']["{$rawKeyBase}_8"];
}
$status = CommonITILObject::getStatusClass($status);
echo '<li data-itemtype="PluginFormcreatorFormanswer" data-id="' . $formAnswer['raw']["${rawKeyBase}_2"] . '">';
echo '<i class="'.$status.'"></i><a href="formanswer.form.php?id='. $formAnswer['raw']["${rawKeyBase}_2"] .'">'. $formAnswer['raw']["${rawKeyBase}_1"] .'</a>';
echo '<span class="plugin_formcreator_date">'.Html::convDateTime($formAnswer['raw']["${rawKeyBase}_6"]).'</span>';
echo '<li data-itemtype="PluginFormcreatorFormanswer" data-id="' . $formAnswer['raw']["{$rawKeyBase}_2"] . '">';
echo '<i class="'.$status.'"></i><a href="formanswer.form.php?id='. $formAnswer['raw']["{$rawKeyBase}_2"] .'">'. $formAnswer['raw']["{$rawKeyBase}_1"] .'</a>';
echo '<span class="plugin_formcreator_date">'.Html::convDateTime($formAnswer['raw']["{$rawKeyBase}_6"]).'</span>';
echo '</li>';
}
echo '</ul>';
Expand Down Expand Up @@ -2385,7 +2385,7 @@ public static function getTranslationDomain($id, $language = '') {
if ($language == '') {
$language = $_SESSION['glpilanguage'];
}
return "form_${id}_${language}";
return "form_{$id}_{$language}";
}

/**
Expand Down
4 changes: 2 additions & 2 deletions inc/form_validator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ public static function dropdownValidator(PluginFormcreatorForm $form): string {
continue;
}
$validatorId = $validator->getID();
$validators["${itemtype}_${validatorId}"] = $validator->getFriendlyName();
$validators["{$itemtype}_{$validatorId}"] = $validator->getFriendlyName();
$lastValidatorId = $validatorId;
$lastValidatorItemtype = $itemtype;
}
Expand All @@ -702,7 +702,7 @@ public static function dropdownValidator(PluginFormcreatorForm $form): string {
if ($totalCount == 1) {
reset($validators);
$validatorId = key($validators);
return Html::hidden('formcreator_validator', ['value' => "${lastValidatorItemtype}_${lastValidatorId}"]);
return Html::hidden('formcreator_validator', ['value' => "{$lastValidatorItemtype}_{$lastValidatorId}"]);
}

$out = '';
Expand Down
6 changes: 3 additions & 3 deletions inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,14 +778,14 @@ protected function getTargetTemplate(array $data): int {
$targetTemplateFk = $targetItemtype::getForeignKeyField();
if ($targetItemtype::isNewID($this->fields[$targetTemplateFk]) && !ITILCategory::isNewID($data['itilcategories_id'])) {
$rows = $DB->request([
'SELECT' => ["${targetTemplateFk}_incident", "${targetTemplateFk}_demand"],
'SELECT' => ["{$targetTemplateFk}_incident", "{$targetTemplateFk}_demand"],
'FROM' => ITILCategory::getTable(),
'WHERE' => ['id' => $data['itilcategories_id']]
]);
if ($row = $rows->current()) { // assign ticket template according to resulting ticket category and ticket type
return ($data['type'] == Ticket::INCIDENT_TYPE
? $row["${targetTemplateFk}_incident"]
: $row["${targetTemplateFk}_demand"]);
? $row["{$targetTemplateFk}_incident"]
: $row["{$targetTemplateFk}_demand"]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ function plugin_formcreator_getSchemaPath(string $version = null): ?string {
preg_match('/^(\d+\.\d+\.\d+)/', $version, $matches);
$version = $matches[1];

return Plugin::getPhpDir('formcreator') . "/install/mysql/plugin_formcreator_${version}_empty.sql";
return Plugin::getPhpDir('formcreator') . "/install/mysql/plugin_formcreator_{$version}_empty.sql";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/1-install/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function testUpgradedPlugin() {

$pluginName = TEST_PLUGIN_NAME;

$fresh_tables = $DB->listTables("glpi_plugin_${pluginName}_%");
$fresh_tables = $DB->listTables("glpi_plugin_{$pluginName}_%");
foreach ($fresh_tables as $fresh_table) {
$table = $fresh_table['TABLE_NAME'];
$this->boolean($this->olddb->tableExists($table, false))
Expand Down
6 changes: 3 additions & 3 deletions tests/3-unit/PluginFormcreatorFormAnswer.php
Original file line number Diff line number Diff line change
Expand Up @@ -805,13 +805,13 @@ public function testGetFileProperties() {
copy(dirname(__DIR__) . '/fixture/upload.txt', GLPI_TMP_DIR . '/' . $filename);
$formAnswer = $this->getFormAnswer([
'plugin_formcreator_forms_id' => $form->getID(),
"_${fieldKey}" => [
"_{$fieldKey}" => [
$filename,
],
"_prefix_${fieldKey}" => [
"_prefix_{$fieldKey}" => [
'5e5e92ffd9bd91.44444444',
],
"_tag_${fieldKey}" => [
"_tag_{$fieldKey}" => [
$tag,
],
]);
Expand Down
4 changes: 2 additions & 2 deletions tests/src/CommonTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ public function afterTestMethod($method) {
$class = static::class;
$class = str_replace('\\', '_', $class);
if ($fileSqlContent != '') {
rename(GLPI_LOG_DIR."/sql-errors.log", GLPI_LOG_DIR."/sql-errors__${class}__$method.log");
rename(GLPI_LOG_DIR."/sql-errors.log", GLPI_LOG_DIR."/sql-errors__{$class}__$method.log");
}
if ($fileSqlContent != '') {
rename(GLPI_LOG_DIR."/php-errors.log", GLPI_LOG_DIR."/php-errors__${class}__$method.log");
rename(GLPI_LOG_DIR."/php-errors.log", GLPI_LOG_DIR."/php-errors__{$class}__$method.log");
}

// Reset log files
Expand Down

0 comments on commit 4bb7f3c

Please sign in to comment.