From 98be5d5be772299e6c9a407ccbdb4bc7d91a2167 Mon Sep 17 00:00:00 2001 From: raviks789 Date: Thu, 11 Apr 2024 17:24:14 +0200 Subject: [PATCH] Remove unnecessary type hints --- application/controllers/EventRuleController.php | 6 ------ application/controllers/EventRulesController.php | 9 --------- .../EventRuleConfigElements/EscalationCondition.php | 3 --- .../EventRuleConfigElements/EscalationRecipient.php | 6 ------ application/forms/EventRuleConfigForm.php | 11 ----------- 5 files changed, 35 deletions(-) diff --git a/application/controllers/EventRuleController.php b/application/controllers/EventRuleController.php index a48d8af51..8eb5ec0b3 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']); @@ -98,7 +96,6 @@ public function indexAction(): void }) ->handleRequest($this->getServerRequest()); - /** @var array $cache */ $cache = $this->sessionNamespace->get($ruleId); $discardChangesButton = null; if ($cache !== null) { @@ -187,7 +184,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; } } @@ -244,7 +240,6 @@ public function searchEditorAction(): void $editor = new SearchEditor(); - /** @var string $objectFilter */ $objectFilter = $eventRule['object_filter'] ?? ''; $editor->setQueryString($objectFilter) ->setAction(Url::fromRequest()->getAbsoluteUrl()) @@ -295,7 +290,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 0c55a41a7..e320b633b 100644 --- a/application/controllers/EventRulesController.php +++ b/application/controllers/EventRulesController.php @@ -108,15 +108,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; } @@ -140,9 +137,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); @@ -174,10 +169,7 @@ public function addAction(): 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) { @@ -186,7 +178,6 @@ public function searchEditorAction(): void $editor = new SearchEditor(); - /** @var string $objectFilter */ $objectFilter = $eventRule['object_filter'] ?? ''; $editor->setQueryString($objectFilter) ->setAction(Url::fromRequest()->getAbsoluteUrl()) diff --git a/application/forms/EventRuleConfigElements/EscalationCondition.php b/application/forms/EventRuleConfigElements/EscalationCondition.php index 0c3d1dd4e..2a3873ee0 100644 --- a/application/forms/EventRuleConfigElements/EscalationCondition.php +++ b/application/forms/EventRuleConfigElements/EscalationCondition.php @@ -51,7 +51,6 @@ protected function assemble(): void ['value' => (string) $defaultCount] ); - /** @var SubmitButtonElement $addCondition */ $addCondition = $this->createElement( 'submitButton', 'add-condition', @@ -65,7 +64,6 @@ protected function assemble(): void $this->registerElement($addCondition); - /** @var string|int $conditionCount */ $conditionCount = $this->getValue('condition-count'); $conditionCount = (int) $conditionCount; $this->addElement('hidden', 'id'); @@ -240,7 +238,6 @@ 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; diff --git a/application/forms/EventRuleConfigElements/EscalationRecipient.php b/application/forms/EventRuleConfigElements/EscalationRecipient.php index ec9dc4e06..24713b61d 100644 --- a/application/forms/EventRuleConfigElements/EscalationRecipient.php +++ b/application/forms/EventRuleConfigElements/EscalationRecipient.php @@ -24,7 +24,6 @@ protected function assemble(): void { $this->addElement('hidden', 'recipient-count', ['value' => '1']); - /** @var SubmitButtonElement $addRecipientButton */ $addRecipientButton = $this->createElement( 'submitButton', 'add-recipient', @@ -37,7 +36,6 @@ protected function assemble(): void ); $this->registerElement($addRecipientButton); - /** @var int $recipientCount */ $recipientCount = $this->getValue('recipient-count'); if ($addRecipientButton->hasBeenPressed()) { $recipientCount += 1; @@ -66,7 +64,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, @@ -78,7 +75,6 @@ protected function assemble(): void ] ); - /** @var string $recipientVal */ $recipientVal = $this->getValue('column_' . $i); if ($recipientVal !== null) { $recipient = explode('_', $recipientVal); @@ -169,7 +165,6 @@ protected function fetchOptions(): array */ protected function createRemoveButton(int $pos): ?SubmitButtonElement { - /** @var string|int $recipientCount */ $recipientCount = $this->getValue('recipient-count'); if ((int) $recipientCount === 1) { return null; @@ -207,7 +202,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 066fa3c00..c1d48cfbe 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 = []; @@ -279,7 +273,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)); @@ -497,7 +490,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 = []; @@ -558,7 +550,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', [ @@ -569,7 +560,6 @@ private function insertOrUpdateEscalations( 'fallback_for' => $escalationConfig['fallback_for'] ?? null ]); - /** @var string $escalationId */ $escalationId = $db->lastInsertId(); } else { /** @var string $escalationId */ @@ -609,7 +599,6 @@ function (array $element) use ($recipientId) { } } - /** @var array $recipientConfig */ foreach ($recipientsFromConfig as $recipientConfig) { $data = [ 'rule_escalation_id' => $escalationId,