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 11, 2024
1 parent 804242c commit 473161f
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 46 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);

Check failure on line 54 in application/controllers/EventRuleController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Parameter #1 $key of method Icinga\Web\Session\SessionNamespace::get() expects string, mixed given.

Check failure on line 54 in application/controllers/EventRuleController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Parameter #1 $key of method Icinga\Web\Session\SessionNamespace::get() expects string, mixed given.

Check failure on line 54 in application/controllers/EventRuleController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #1 $key of method Icinga\Web\Session\SessionNamespace::get() expects string, mixed given.

Check failure on line 54 in application/controllers/EventRuleController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #1 $key of method Icinga\Web\Session\SessionNamespace::get() expects string, mixed given.

Check failure on line 54 in application/controllers/EventRuleController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Parameter #1 $key of method Icinga\Web\Session\SessionNamespace::get() expects string, mixed given.

Check failure on line 54 in application/controllers/EventRuleController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Parameter #1 $key of method Icinga\Web\Session\SessionNamespace::get() expects string, mixed given.

Check failure on line 54 in application/controllers/EventRuleController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Parameter #1 $key of method Icinga\Web\Session\SessionNamespace::get() expects string, mixed given.
$this->controls->addAttributes(['class' => 'event-rule-detail']);

Expand Down Expand Up @@ -99,7 +97,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 @@ -189,7 +186,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 @@ -246,7 +242,6 @@ public function searchEditorAction(): void

$editor = new SearchEditor();

/** @var string $objectFilter */
$objectFilter = $eventRule['object_filter'] ?? '';
$editor->setQueryString($objectFilter);
$editor->setAction(Url::fromRequest()->getAbsoluteUrl());
Expand Down Expand Up @@ -303,7 +298,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 @@ -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<string, mixed>|null $config */
$config = $this->sessionNamespace->get($ruleId);

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

Expand All @@ -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);
Expand Down Expand Up @@ -181,10 +176,7 @@ public function completeAction(): 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 @@ -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());
Expand Down
11 changes: 0 additions & 11 deletions application/forms/EventRuleConfigElements/EscalationCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ protected function assemble(): void
['value' => (string) $defaultCount]
);

/** @var SubmitButtonElement $addCondition */
$addCondition = $this->createElement(
'submitButton',
'add-condition',
Expand All @@ -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(
Expand All @@ -88,7 +86,6 @@ protected function assemble(): void
$typeName = 'type_' . $i;
$valName = 'val_' . $i;

/** @var BaseFormElement $col */
$col = $this->createElement(
'select',
$colName,
Expand All @@ -105,7 +102,6 @@ protected function assemble(): void
);

$operators = ['=', '>', '>=', '<', '<=', '!='];
/** @var BaseFormElement $op */
$op = $this->createElement(
'select',
$opName,
Expand All @@ -118,7 +114,6 @@ protected function assemble(): void

switch ($this->getPopulatedValue('column_' . $i)) {
case 'incident_severity':
/** @var BaseFormElement $val */
$val = $this->createElement(
'select',
$valName,
Expand Down Expand Up @@ -152,7 +147,6 @@ protected function assemble(): void

break;
case 'incident_age':
/** @var BaseFormElement $val */
$val = $this->createElement(
'text',
$valName,
Expand Down Expand Up @@ -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'),
Expand All @@ -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(
Expand All @@ -217,7 +209,6 @@ protected function assemble(): void
);
}

/** @var string $removePosition */
$removePosition = $this->getValue('remove');
if ($removePosition) {
unset($this->conditions[$removePosition]);
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ protected function assemble(): void
['value' => '1']
);

/** @var SubmitButtonElement $addRecipientButton */
$addRecipientButton = $this->createElement(
'submitButton',
'add-recipient',
Expand All @@ -44,7 +43,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 @@ -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,
Expand All @@ -89,7 +86,6 @@ protected function assemble(): void
]
);

/** @var string $recipientVal */
$recipientVal = $this->getValue('column_' . $i);
if ($recipientVal !== null) {
$recipient = explode('_', $recipientVal);
Expand All @@ -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'),
Expand All @@ -116,7 +111,6 @@ protected function assemble(): void

$this->registerElement($val);

/** @var ?SubmitButtonElement $removeButton */
$removeButton = $this->createRemoveButton($i);

$this->recipients[$i] = new EscalationRecipientListItem(
Expand All @@ -126,7 +120,6 @@ protected function assemble(): void
);
}

/** @var string $removePosition */
$removePosition = $this->getValue('remove');
if ($removePosition) {
unset($this->recipients[$removePosition]);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -228,7 +220,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 @@ -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));
Expand Down Expand Up @@ -508,7 +501,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 @@ -567,7 +559,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 @@ -578,7 +569,6 @@ private function insertOrUpdateEscalations(
'fallback_for' => $escalationConfig['fallback_for'] ?? null
]);

/** @var string $escalationId */
$escalationId = $db->lastInsertId();
} else {
/** @var string $escalationId */
Expand Down Expand Up @@ -618,7 +608,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 473161f

Please sign in to comment.