From 12e7c5ea394880cf1a80711df37e4b00cb92f77b Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 16 Jul 2024 12:29:02 +0200 Subject: [PATCH] Replace functions that are not available in php72 --- application/forms/EscalationConditionForm.php | 2 +- application/forms/EscalationRecipientForm.php | 2 +- application/forms/SaveEventRuleForm.php | 2 +- library/Notifications/Widget/EventRuleConfig.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/forms/EscalationConditionForm.php b/application/forms/EscalationConditionForm.php index 96b6b51d..f4981250 100644 --- a/application/forms/EscalationConditionForm.php +++ b/application/forms/EscalationConditionForm.php @@ -257,7 +257,7 @@ protected function handleRemove(): void unset($this->options[$toRemove]); if ($this->deleteRemoveButton && count($this->options) === 1) { - $key = array_key_last($this->options); + $key = key($this->options); $this->options[$key]->remove($this->getElement('remove_' . $key)); } } diff --git a/application/forms/EscalationRecipientForm.php b/application/forms/EscalationRecipientForm.php index 006d71a8..28b7a6c0 100644 --- a/application/forms/EscalationRecipientForm.php +++ b/application/forms/EscalationRecipientForm.php @@ -224,7 +224,7 @@ protected function handleRemove(): void unset($this->options[$toRemove]); if (count($this->options) === 1) { - $key = array_key_last($this->options); + $key = key($this->options); $this->options[$key]->remove($this->getElement('remove_' . $key)); } } diff --git a/application/forms/SaveEventRuleForm.php b/application/forms/SaveEventRuleForm.php index f19f25b1..64c68e7a 100644 --- a/application/forms/SaveEventRuleForm.php +++ b/application/forms/SaveEventRuleForm.php @@ -413,7 +413,7 @@ public function editRule(int $id, array $config): void }); if ($escalationInCache) { - $position = array_key_first($escalationInCache); + $position = key($escalationInCache); // Escalations in DB to update $escalationsToUpdate[$position] = $escalationInCache[$position]; unset($escalationsInCache[$position]); diff --git a/library/Notifications/Widget/EventRuleConfig.php b/library/Notifications/Widget/EventRuleConfig.php index 1ae0a4f9..5adc36bc 100644 --- a/library/Notifications/Widget/EventRuleConfig.php +++ b/library/Notifications/Widget/EventRuleConfig.php @@ -83,7 +83,7 @@ protected function createForms(): void $addEscalation = (new AddEscalationForm()) ->on(AddEscalationForm::ON_SENT, function () use ($escalations) { - $newPosition = (int) array_key_last($escalations) + 1; + $newPosition = count($escalations) + 1; $this->config['rule_escalation'][$newPosition] = ['id' => $this->generateFakeEscalationId()]; if ($this->config['conditionPlusButtonPosition'] === null) { $this->config['conditionPlusButtonPosition'] = $newPosition;