diff --git a/application/controllers/EventRuleController.php b/application/controllers/EventRuleController.php index bcdc64d75..f4512babf 100644 --- a/application/controllers/EventRuleController.php +++ b/application/controllers/EventRuleController.php @@ -50,9 +50,7 @@ public function indexAction(): void $this->addTitleTab(t('Event Rule')); $this->controls->addAttributes(['class' => 'event-rule-detail']); - /** @var string $ruleId */ $ruleId = $this->params->getRequired('id'); - /** @var array|null $configValues */ $configValues = $this->sessionNamespace->get($ruleId); $this->controls->addAttributes(['class' => 'event-rule-detail']); @@ -99,7 +97,6 @@ public function indexAction(): void }) ->handleRequest($this->getServerRequest()); - /** @var array $cache */ $cache = $this->sessionNamespace->get($ruleId); $discardChangesButton = null; if ($cache !== null) { @@ -188,7 +185,6 @@ public function fromDb(int $ruleId): array foreach ($rule->rule_escalation as $re) { foreach ($re as $k => $v) { if (in_array($k, ['id', 'condition'])) { - /** @var int|string|null $v */ $config[$re->getTableName()][$re->position][$k] = (string) $v; } } @@ -245,7 +241,6 @@ public function searchEditorAction(): void $editor = new SearchEditor(); - /** @var string $objectFilter */ $objectFilter = $eventRule['object_filter'] ?? ''; $editor->setQueryString($objectFilter); $editor->setAction(Url::fromRequest()->getAbsoluteUrl()); @@ -302,7 +297,6 @@ public function editAction(): void { /** @var string $ruleId */ $ruleId = $this->params->getRequired('id'); - /** @var array|null $config */ $config = $this->sessionNamespace->get($ruleId); if ($config === null) { if ($ruleId === '-1') { diff --git a/application/controllers/EventRulesController.php b/application/controllers/EventRulesController.php index f876c7f7a..c76b57b29 100644 --- a/application/controllers/EventRulesController.php +++ b/application/controllers/EventRulesController.php @@ -107,15 +107,12 @@ public function addAction(): void $this->getTabs()->setRefreshUrl(Url::fromPath('notifications/event-rules/add')); $this->controls->addAttributes(['class' => 'event-rule-detail']); - /** @var string $ruleId */ $ruleId = $this->params->get('id') ?? '-1'; $params = $this->params->toArray(false); - /** @var array|null $config */ $config = $this->sessionNamespace->get($ruleId); if ($config === null) { - /** @var array $config */ $config = $params; } @@ -139,9 +136,7 @@ public function addAction(): void $eventRuleConfig ->on(Form::ON_SUCCESS, function (EventRuleConfigForm $form) use ($config) { - /** @var string $ruleId */ $ruleId = $config['id']; - /** @var string $ruleName */ $ruleName = $config['name']; $form->addOrUpdateRule($ruleId, $config); $this->sessionNamespace->delete($ruleId); @@ -181,10 +176,7 @@ public function completeAction(): void public function searchEditorAction(): void { - /** @var string $ruleId */ $ruleId = $this->params->shiftRequired('id'); - - /** @var array|null $eventRule */ $eventRule = $this->sessionNamespace->get($ruleId); if ($eventRule === null) { @@ -193,7 +185,6 @@ public function searchEditorAction(): void $editor = new SearchEditor(); - /** @var string $objectFilter */ $objectFilter = $eventRule['object_filter'] ?? ''; $editor->setQueryString($objectFilter); $editor->setAction(Url::fromRequest()->getAbsoluteUrl()); diff --git a/application/forms/EventRuleConfigElements/EscalationCondition.php b/application/forms/EventRuleConfigElements/EscalationCondition.php index 94001a476..75fe3dc6c 100644 --- a/application/forms/EventRuleConfigElements/EscalationCondition.php +++ b/application/forms/EventRuleConfigElements/EscalationCondition.php @@ -55,7 +55,6 @@ protected function assemble(): void ['value' => (string) $defaultCount] ); - /** @var SubmitButtonElement $addCondition */ $addCondition = $this->createElement( 'submitButton', 'add-condition', @@ -69,7 +68,6 @@ protected function assemble(): void $this->registerElement($addCondition); - /** @var string|int $conditionCount */ $conditionCount = $this->getValue('condition-count'); $conditionCount = (int) $conditionCount; $this->addElement( @@ -88,7 +86,6 @@ protected function assemble(): void $typeName = 'type_' . $i; $valName = 'val_' . $i; - /** @var BaseFormElement $col */ $col = $this->createElement( 'select', $colName, @@ -105,7 +102,6 @@ protected function assemble(): void ); $operators = ['=', '>', '>=', '<', '<=', '!=']; - /** @var BaseFormElement $op */ $op = $this->createElement( 'select', $opName, @@ -118,7 +114,6 @@ protected function assemble(): void switch ($this->getPopulatedValue('column_' . $i)) { case 'incident_severity': - /** @var BaseFormElement $val */ $val = $this->createElement( 'select', $valName, @@ -152,7 +147,6 @@ protected function assemble(): void break; case 'incident_age': - /** @var BaseFormElement $val */ $val = $this->createElement( 'text', $valName, @@ -193,7 +187,6 @@ protected function assemble(): void break; default: - /** @var BaseFormElement $val */ $val = $this->createElement('text', $valName, [ 'class' => 'right-operand', 'placeholder' => $this->translate('Please make a decision'), @@ -206,7 +199,6 @@ protected function assemble(): void $this->registerElement($val); (new EventRuleDecorator())->decorate($val); - /** @var ?SubmitButtonElement $removeButton */ $removeButton = $this->createRemoveButton($i); $this->conditions[$i] = new EscalationConditionListItem( @@ -217,7 +209,6 @@ protected function assemble(): void ); } - /** @var string $removePosition */ $removePosition = $this->getValue('remove'); if ($removePosition) { unset($this->conditions[$removePosition]); @@ -261,13 +252,11 @@ protected function assemble(): void protected function createRemoveButton(int $count): ?SubmitButtonElement { // check for count and if allow zero conditions - /** @var string|int $conditionCount */ $conditionCount = $this->getValue('condition-count'); if ((int) $conditionCount === 1 && ! $this->allowZeroConditions) { return null; } - /** @var SubmitButtonElement $removeButton */ $removeButton = $this->createElement( 'submitButton', 'remove', diff --git a/application/forms/EventRuleConfigElements/EscalationRecipient.php b/application/forms/EventRuleConfigElements/EscalationRecipient.php index e4b1167c0..7f4312556 100644 --- a/application/forms/EventRuleConfigElements/EscalationRecipient.php +++ b/application/forms/EventRuleConfigElements/EscalationRecipient.php @@ -31,7 +31,6 @@ protected function assemble(): void ['value' => '1'] ); - /** @var SubmitButtonElement $addRecipientButton */ $addRecipientButton = $this->createElement( 'submitButton', 'add-recipient', @@ -44,7 +43,6 @@ protected function assemble(): void ); $this->registerElement($addRecipientButton); - /** @var int $recipientCount */ $recipientCount = $this->getValue('recipient-count'); if ($addRecipientButton->hasBeenPressed()) { $recipientCount += 1; @@ -77,7 +75,6 @@ protected function assemble(): void $options = ['' => sprintf(' - %s - ', $this->translate('Please choose'))]; $options += Channel::fetchChannelNames(Database::get()); - /** @var SelectElement $val */ $val = $this->createElement( 'select', 'val_' . $i, @@ -89,7 +86,6 @@ protected function assemble(): void ] ); - /** @var string $recipientVal */ $recipientVal = $this->getValue('column_' . $i); if ($recipientVal !== null) { $recipient = explode('_', $recipientVal); @@ -105,7 +101,6 @@ protected function assemble(): void } } } else { - /** @var BaseFormElement $val */ $val = $this->createElement('text', 'val_' . $i, [ 'class' => 'right-operand', 'placeholder' => $this->translate('Please make a decision'), @@ -116,7 +111,6 @@ protected function assemble(): void $this->registerElement($val); - /** @var ?SubmitButtonElement $removeButton */ $removeButton = $this->createRemoveButton($i); $this->recipients[$i] = new EscalationRecipientListItem( @@ -126,7 +120,6 @@ protected function assemble(): void ); } - /** @var string $removePosition */ $removePosition = $this->getValue('remove'); if ($removePosition) { unset($this->recipients[$removePosition]); @@ -189,7 +182,6 @@ protected function fetchOptions(): array */ protected function createRemoveButton(int $pos): ?FormElement { - /** @var string|int $recipientCount */ $recipientCount = $this->getValue('recipient-count'); if ((int) $recipientCount === 1) { return null; @@ -228,7 +220,6 @@ public function getRecipients(): array /** @var int $count */ $count = $this->getValue('recipient-count'); - /** @var array> $values */ $values = []; for ($i = 1; $i <= $count; $i++) { $value = []; diff --git a/application/forms/EventRuleConfigForm.php b/application/forms/EventRuleConfigForm.php index 84cf98dc8..51979799e 100644 --- a/application/forms/EventRuleConfigForm.php +++ b/application/forms/EventRuleConfigForm.php @@ -125,7 +125,6 @@ protected function assemble(): void ] ); - /** @var string $ruleId */ $ruleId = $this->config['id']; if ($ruleId === '-1') { $initialZeroConditionEscalation = bin2hex('1'); @@ -139,7 +138,6 @@ protected function assemble(): void ['value' => $initialZeroConditionEscalation] ); - /** @var string $objectFilter */ $objectFilter = $this->config['object_filter'] ?? ''; $configFilter = (new EventRuleConfigFilter('config-filter')) ->setObjectFilter($objectFilter) @@ -168,10 +166,8 @@ protected function assemble(): void $this->addElement($prefixesElement); $this->handleAdd(); - /** @var string $prefixesMapString */ $prefixesMapString = $prefixesElement->getValue(); - /** @var array $prefixesMap */ $prefixesMap = explode(',', $prefixesMapString); $escalationCount = count($prefixesMap); @@ -183,7 +179,6 @@ protected function assemble(): void $removeEscalationButtons[$prefixMap] = $this->createRemoveButton($prefixMap); } - /** @var ?string $removePosition */ $removePosition = $this->getValue('remove-escalation'); if ($removePosition) { if ($escalationCount === 2) { @@ -191,7 +186,6 @@ protected function assemble(): void } } - /** @var ?string $zeroConditionEscalation */ $zeroConditionEscalation = $this->getValue('zero-condition-escalation'); $escalations = []; @@ -280,7 +274,6 @@ protected function handleAdd(): void if ($pressedButton && $pressedButton->getName() === 'add-escalation') { $this->clearPopulatedValue('prefixes-map'); - /** @var string $prefixesMapString */ $prefixesMapString = $this->getValue('prefixes-map'); $prefixesMap = explode(',', $prefixesMapString); $escalationFakePos = bin2hex(random_bytes(4)); @@ -508,7 +501,6 @@ public function addOrUpdateRule(string $id, array $config): void $escalationsFromDb = RuleEscalation::on($db) ->filter(Filter::equal('rule_id', $id)); - /** @var array> $escalationsInCache */ $escalationsInCache = $config['rule_escalation']; $escalationsToUpdate = []; @@ -567,7 +559,6 @@ private function insertOrUpdateEscalations( bool $insert = false ): void { foreach ($escalations as $position => $escalationConfig) { - /** @var array> $recipientsFromConfig */ $recipientsFromConfig = $escalationConfig['recipients'] ?? []; if ($insert) { $db->insert('rule_escalation', [ @@ -578,7 +569,6 @@ private function insertOrUpdateEscalations( 'fallback_for' => $escalationConfig['fallback_for'] ?? null ]); - /** @var string $escalationId */ $escalationId = $db->lastInsertId(); } else { /** @var string $escalationId */ @@ -618,7 +608,6 @@ function (array $element) use ($recipientId) { } } - /** @var array $recipientConfig */ foreach ($recipientsFromConfig as $recipientConfig) { $data = [ 'rule_escalation_id' => $escalationId,