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;