Skip to content

Commit

Permalink
Remove unnecessary type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
raviks789 committed Apr 24, 2024
1 parent b911f63 commit 98be5d5
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 35 deletions.
6 changes: 0 additions & 6 deletions application/controllers/EventRuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>|null $configValues */
$configValues = $this->sessionNamespace->get($ruleId);
$this->controls->addAttributes(['class' => 'event-rule-detail']);

Expand Down Expand Up @@ -98,7 +96,6 @@ public function indexAction(): void
})
->handleRequest($this->getServerRequest());

/** @var array<string, mixed> $cache */
$cache = $this->sessionNamespace->get($ruleId);
$discardChangesButton = null;
if ($cache !== null) {
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -295,7 +290,6 @@ public function editAction(): void
{
/** @var string $ruleId */
$ruleId = $this->params->getRequired('id');
/** @var array<string, mixed>|null $config */
$config = $this->sessionNamespace->get($ruleId);
if ($config === null) {
if ($ruleId === '-1') {
Expand Down
9 changes: 0 additions & 9 deletions application/controllers/EventRulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>|null $config */
$config = $this->sessionNamespace->get($ruleId);

if ($config === null) {
/** @var array<string, mixed> $config */
$config = $params;
}

Expand All @@ -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);
Expand Down Expand Up @@ -174,10 +169,7 @@ public function addAction(): void

public function searchEditorAction(): void
{
/** @var string $ruleId */
$ruleId = $this->params->shiftRequired('id');

/** @var array<string, mixed>|null $eventRule */
$eventRule = $this->sessionNamespace->get($ruleId);

if ($eventRule === null) {
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ protected function assemble(): void
['value' => (string) $defaultCount]
);

/** @var SubmitButtonElement $addCondition */
$addCondition = $this->createElement(
'submitButton',
'add-condition',
Expand All @@ -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');
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ protected function assemble(): void
{
$this->addElement('hidden', 'recipient-count', ['value' => '1']);

/** @var SubmitButtonElement $addRecipientButton */
$addRecipientButton = $this->createElement(
'submitButton',
'add-recipient',
Expand All @@ -37,7 +36,6 @@ protected function assemble(): void
);

$this->registerElement($addRecipientButton);
/** @var int $recipientCount */
$recipientCount = $this->getValue('recipient-count');
if ($addRecipientButton->hasBeenPressed()) {
$recipientCount += 1;
Expand Down Expand Up @@ -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,
Expand All @@ -78,7 +75,6 @@ protected function assemble(): void
]
);

/** @var string $recipientVal */
$recipientVal = $this->getValue('column_' . $i);
if ($recipientVal !== null) {
$recipient = explode('_', $recipientVal);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -207,7 +202,6 @@ public function getRecipients(): array
/** @var int $count */
$count = $this->getValue('recipient-count');

/** @var array<int, array<string, mixed>> $values */
$values = [];
for ($i = 1; $i <= $count; $i++) {
$value = [];
Expand Down
11 changes: 0 additions & 11 deletions application/forms/EventRuleConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ protected function assemble(): void
]
);

/** @var string $ruleId */
$ruleId = $this->config['id'];
if ($ruleId === '-1') {
$initialZeroConditionEscalation = bin2hex('1');
Expand All @@ -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)
Expand Down Expand Up @@ -168,10 +166,8 @@ protected function assemble(): void
$this->addElement($prefixesElement);
$this->handleAdd();

/** @var string $prefixesMapString */
$prefixesMapString = $prefixesElement->getValue();

/** @var array<int, string> $prefixesMap */
$prefixesMap = explode(',', $prefixesMapString);
$escalationCount = count($prefixesMap);

Expand All @@ -183,15 +179,13 @@ protected function assemble(): void
$removeEscalationButtons[$prefixMap] = $this->createRemoveButton($prefixMap);
}

/** @var ?string $removePosition */
$removePosition = $this->getValue('remove-escalation');
if ($removePosition) {
if ($escalationCount === 2) {
$removeEscalationButtons = [];
}
}

/** @var ?string $zeroConditionEscalation */
$zeroConditionEscalation = $this->getValue('zero-condition-escalation');

$escalations = [];
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -497,7 +490,6 @@ public function addOrUpdateRule(string $id, array $config): void
$escalationsFromDb = RuleEscalation::on($db)
->filter(Filter::equal('rule_id', $id));

/** @var array<int, array<string, mixed>> $escalationsInCache */
$escalationsInCache = $config['rule_escalation'];

$escalationsToUpdate = [];
Expand Down Expand Up @@ -558,7 +550,6 @@ private function insertOrUpdateEscalations(
bool $insert = false
): void {
foreach ($escalations as $position => $escalationConfig) {
/** @var array<int, array<string, mixed>> $recipientsFromConfig */
$recipientsFromConfig = $escalationConfig['recipients'] ?? [];
if ($insert) {
$db->insert('rule_escalation', [
Expand All @@ -569,7 +560,6 @@ private function insertOrUpdateEscalations(
'fallback_for' => $escalationConfig['fallback_for'] ?? null
]);

/** @var string $escalationId */
$escalationId = $db->lastInsertId();
} else {
/** @var string $escalationId */
Expand Down Expand Up @@ -609,7 +599,6 @@ function (array $element) use ($recipientId) {
}
}

/** @var array<string, mixed> $recipientConfig */
foreach ($recipientsFromConfig as $recipientConfig) {
$data = [
'rule_escalation_id' => $escalationId,
Expand Down

0 comments on commit 98be5d5

Please sign in to comment.