Skip to content

Commit 9238dc4

Browse files
Add method return types and remove superfluous $db property
1 parent 4cdba0c commit 9238dc4

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

application/controllers/ChannelsController.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Icinga\Web\Notification;
1616
use Icinga\Web\Widget\Tab;
1717
use Icinga\Web\Widget\Tabs;
18-
use ipl\Sql\Connection;
1918
use ipl\Sql\Expression;
2019
use ipl\Stdlib\Filter;
2120
use ipl\Web\Compat\CompatController;
@@ -30,22 +29,17 @@ class ChannelsController extends CompatController
3029
{
3130
use SearchControls;
3231

33-
/** @var Connection */
34-
private $db;
35-
3632
/** @var Filter\Rule Filter from query string parameters */
3733
private $filter;
3834

39-
public function init()
35+
public function init(): void
4036
{
4137
$this->assertPermission('config/modules');
42-
43-
$this->db = Database::get();
4438
}
4539

46-
public function indexAction()
40+
public function indexAction(): void
4741
{
48-
$channels = Channel::on($this->db);
42+
$channels = Channel::on(Database::get());
4943
$this->mergeTabs($this->Module()->getConfigTabs());
5044
$this->getTabs()->activate('channels');
5145

@@ -95,7 +89,7 @@ public function indexAction()
9589
))->setBaseTarget('_next');
9690

9791
$emptyStateMessage = null;
98-
if (AvailableChannelType::on($this->db)->columns([new Expression('1')])->first() === null) {
92+
if (AvailableChannelType::on(Database::get())->columns([new Expression('1')])->first() === null) {
9993
$emptyStateMessage = t('No channel types available. Make sure Icinga Notifications is running.');
10094
$addButton->disable($emptyStateMessage);
10195
}
@@ -112,10 +106,10 @@ public function indexAction()
112106
}
113107
}
114108

115-
public function addAction()
109+
public function addAction(): void
116110
{
117111
$this->addTitleTab(t('Add Channel'));
118-
$form = (new ChannelForm($this->db))
112+
$form = (new ChannelForm(Database::get()))
119113
->on(ChannelForm::ON_SUCCESS, function (ChannelForm $form) {
120114
$form->addChannel();
121115
Notification::success(
@@ -142,7 +136,7 @@ public function completeAction(): void
142136
public function searchEditorAction(): void
143137
{
144138
$editor = $this->createSearchEditor(
145-
Channel::on($this->db),
139+
Channel::on(Database::get()),
146140
[
147141
LimitControl::DEFAULT_LIMIT_PARAM,
148142
SortControl::DEFAULT_SORT_PARAM,

application/forms/ChannelForm.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct(Connection $db)
5959
/**
6060
* @throws ConfigurationError
6161
*/
62-
protected function assemble()
62+
protected function assemble(): void
6363
{
6464
$query = AvailableChannelType::on($this->db)
6565
->columns(['type', 'name', 'config_attrs'])
@@ -164,7 +164,7 @@ protected function assemble()
164164
}
165165
}
166166

167-
public function isValid()
167+
public function isValid(): bool
168168
{
169169
if ($this->getPressedSubmitElement()->getName() === 'delete') {
170170
$csrfElement = $this->getElement('CSRFToken');
@@ -179,7 +179,7 @@ public function isValid()
179179
return parent::isValid();
180180
}
181181

182-
public function hasBeenSubmitted()
182+
public function hasBeenSubmitted(): bool
183183
{
184184
if ($this->getPressedSubmitElement() !== null && $this->getPressedSubmitElement()->getName() === 'delete') {
185185
return true;

0 commit comments

Comments
 (0)