Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0e938f6
Use typed class properties
jrauh01 Nov 24, 2025
93d464d
Use typed method return values
jrauh01 Nov 13, 2025
1c5ca0b
Sort imports
jrauh01 Nov 13, 2025
1a148d2
Document thrown exceptions
jrauh01 Nov 13, 2025
5c8ac14
Use match expressions
jrauh01 Nov 13, 2025
d335b1b
Use modern string functions
jrauh01 Nov 13, 2025
9a5e011
Replace deprecated code
jrauh01 Nov 14, 2025
fef89ba
Explicitly create Attributes
jrauh01 Nov 14, 2025
ee15c03
Add inline type docs
jrauh01 Nov 14, 2025
ef9f679
Use imports
jrauh01 Nov 14, 2025
b88f838
Fix typos
jrauh01 Nov 14, 2025
7952d2f
Adjust method docs
jrauh01 Nov 14, 2025
8993180
Add method param types
jrauh01 Nov 14, 2025
1f788bd
Use nullsafe operator
jrauh01 Nov 14, 2025
ccc6227
Fix indentations and spaces
jrauh01 Nov 24, 2025
c91fd2a
Fix invalid key for select input
jrauh01 Nov 24, 2025
5e815b7
Remove superfluous `$filter` property
jrauh01 Nov 26, 2025
6bbf7fb
Remove properties that use parent value as default
jrauh01 Nov 26, 2025
bbebbca
Fix typo in PHPDoc
jrauh01 Mar 24, 2026
0c6a689
Remove redundant `@var` annotations from typed properties
jrauh01 Mar 24, 2026
f199d36
Use `static` return value where appropriate
jrauh01 Mar 25, 2026
a181f9f
Narrow types where possible
jrauh01 Mar 25, 2026
84eb151
`IdTagAggregator`: Remove unnecessary param annotations
BastianLedererIcinga Apr 29, 2026
5b83a9b
Remove `NoSubjectLink` and `EventRuleDecorator`
BastianLedererIcinga Apr 29, 2026
c9a1d13
Remove unused imports
BastianLedererIcinga Apr 30, 2026
0f538b9
Cleanup phpstan-baseline
BastianLedererIcinga Apr 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions application/controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

namespace Icinga\Module\Notifications\Controllers;

use Exception;
use Icinga\Exception\Http\HttpBadRequestException;
use Icinga\Module\Notifications\Api\Middleware\DispatchMiddleware;
use Icinga\Module\Notifications\Api\Middleware\EndpointExecutionMiddleware;
use Icinga\Module\Notifications\Api\Middleware\ErrorHandlingMiddleware;
Expand All @@ -15,7 +13,6 @@
use Icinga\Module\Notifications\Api\Middleware\RoutingMiddleware;
use Icinga\Module\Notifications\Api\Middleware\ValidationMiddleware;
use Icinga\Security\SecurityException;
use Icinga\Web\Request;
use ipl\Web\Compat\CompatController;
use Psr\Http\Message\ResponseInterface;

Expand All @@ -27,6 +24,7 @@ class ApiController extends CompatController
* Processes API requests for the Notifications module, serving as the main entry point for all API interactions.
*
* @return never
*
* @throws SecurityException
*/
public function indexAction(): never
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/ChannelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Forms\ChannelForm;
use Icinga\Web\Notification;
use ipl\Html\Contract\Form;
use ipl\Web\Compat\CompatController;

class ChannelController extends CompatController
Expand All @@ -22,7 +23,7 @@ public function indexAction(): void
$channelId = $this->params->getRequired('id');
$form = (new ChannelForm(Database::get()))
->loadChannel($channelId)
->on(ChannelForm::ON_SUCCESS, function (ChannelForm $form) {
->on(Form::ON_SUBMIT, function (ChannelForm $form) {
if ($form->getPressedSubmitElement()->getName() === 'delete') {
$form->removeChannel();
Notification::success(sprintf(
Expand Down
25 changes: 3 additions & 22 deletions application/controllers/ChannelsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
use Icinga\Module\Notifications\Web\Control\SearchBar\ObjectSuggestions;
use Icinga\Module\Notifications\Widget\ItemList\ObjectList;
use Icinga\Web\Notification;
use Icinga\Web\Widget\Tab;
use Icinga\Web\Widget\Tabs;
use ipl\Html\Contract\Form;
use ipl\Sql\Expression;
use ipl\Stdlib\Filter;
use ipl\Web\Compat\CompatController;
use ipl\Web\Compat\SearchControls;
use ipl\Web\Control\LimitControl;
Expand All @@ -30,9 +29,6 @@ class ChannelsController extends CompatController
{
use SearchControls;

/** @var Filter\Rule Filter from query string parameters */
private $filter;

public function init(): void
{
$this->assertPermission('config/modules');
Expand Down Expand Up @@ -65,7 +61,7 @@ public function indexAction(): void

if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) {
if ($searchBar->hasBeenSubmitted()) {
$filter = $this->getFilter();
$filter = QueryString::parse((string) $this->params);
} else {
$this->addControl($searchBar);
$this->sendMultipartUpdate();
Expand Down Expand Up @@ -111,7 +107,7 @@ public function addAction(): void
{
$this->addTitleTab(t('Add Channel'));
$form = (new ChannelForm(Database::get()))
->on(ChannelForm::ON_SUCCESS, function (ChannelForm $form) {
->on(Form::ON_SUBMIT, function (ChannelForm $form) {
$form->addChannel();
Notification::success(
sprintf(
Expand Down Expand Up @@ -148,20 +144,6 @@ public function searchEditorAction(): void
$this->setTitle($this->translate('Adjust Filter'));
}

/**
* Get the filter created from query string parameters
*
* @return Filter\Rule
*/
protected function getFilter(): Filter\Rule
{
if ($this->filter === null) {
$this->filter = QueryString::parse((string) $this->params);
}

return $this->filter;
}

/**
* Merge tabs with other tabs contained in this tab panel
*
Expand All @@ -171,7 +153,6 @@ protected function getFilter(): Filter\Rule
*/
protected function mergeTabs(Tabs $tabs): void
{
/** @var Tab $tab */
foreach ($tabs->getTabs() as $tab) {
$this->tabs->add($tab->getName(), $tab);
}
Expand Down
9 changes: 4 additions & 5 deletions application/controllers/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
use Icinga\Application\Config;
use Icinga\Module\Notifications\Forms\DatabaseConfigForm;
use Icinga\Web\Notification;
use Icinga\Web\Widget\Tab;
use Icinga\Web\Widget\Tabs;
use ipl\Html\Contract\Form;
use ipl\Web\Compat\CompatController;

class ConfigController extends CompatController
{
public function init()
public function init(): void
{
$this->assertPermission('config/modules');

parent::init();
}

public function databaseAction()
public function databaseAction(): void
{
$moduleConfig = Config::module('notifications');
$form = (new DatabaseConfigForm())
->populate($moduleConfig->getSection('database'))
->on(DatabaseConfigForm::ON_SUCCESS, function ($form) use ($moduleConfig) {
->on(Form::ON_SUBMIT, function ($form) use ($moduleConfig) {
$moduleConfig->setSection('database', $form->getValues());
$moduleConfig->saveIni();

Expand All @@ -47,7 +47,6 @@ public function databaseAction()
*/
protected function mergeTabs(Tabs $tabs): void
{
/** @var Tab $tab */
foreach ($tabs->getTabs() as $tab) {
$this->tabs->add($tab->getName(), $tab);
}
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Icinga\Module\Notifications\Web\Form\ContactForm;
use Icinga\Repository\Repository;
use Icinga\Web\Notification;
use ipl\Html\Contract\Form;
use ipl\Web\Compat\CompatController;
use ipl\Web\FormElement\SearchSuggestions;

Expand All @@ -30,7 +31,7 @@ public function indexAction(): void

$form = (new ContactForm(Database::get()))
->loadContact($contactId)
->on(ContactForm::ON_SUCCESS, function (ContactForm $form) {
->on(Form::ON_SUBMIT, function (ContactForm $form) {
$form->editContact();
Notification::success(sprintf(
t('Contact "%s" has successfully been saved'),
Expand Down
8 changes: 5 additions & 3 deletions application/controllers/ContactGroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
use Icinga\Module\Notifications\Widget\Detail\ObjectHeader;
use Icinga\Module\Notifications\Widget\ItemList\ObjectList;
use Icinga\Web\Notification;
use ipl\Html\Form;
use ipl\Html\Attributes;
use ipl\Html\Contract\Form;
use ipl\Html\Text;
use ipl\Stdlib\Filter;
use ipl\Web\Compat\CompatController;
Expand All @@ -36,12 +37,13 @@ public function indexAction(): void
->columns(['id', 'name'])
->filter(Filter::equal('id', $groupId));

/** @var ?Contactgroup $group */
$group = $query->first();
if ($group === null) {
$this->httpNotFound(t('Contact group not found'));
}

$this->controls->addAttributes(['class' => 'contactgroup-detail']);
$this->controls->addAttributes(Attributes::create(['class' => 'contactgroup-detail']));

$this->addControl(new ObjectHeader($group));

Expand Down Expand Up @@ -98,7 +100,7 @@ public function editAction(): void
}
}
})
->on(Form::ON_SUCCESS, function (ContactGroupForm $form) use ($groupId) {
->on(Form::ON_SUBMIT, function (ContactGroupForm $form) use ($groupId) {
$form->editGroup();
Notification::success(sprintf(
t('Successfully updated contact group %s'),
Expand Down
22 changes: 2 additions & 20 deletions application/controllers/ContactGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use ipl\Html\HtmlString;
use ipl\Html\TemplateString;
use ipl\Sql\Expression;
use ipl\Stdlib\Filter;
use ipl\Web\Compat\CompatController;
use ipl\Web\Compat\SearchControls;
use ipl\Web\Control\LimitControl;
Expand All @@ -36,9 +35,6 @@ class ContactGroupsController extends CompatController
use ConfigurationTabs;
use SearchControls;

/** @var Filter\Rule Filter from query string parameters */
private $filter;

public function init(): void
{
$this->assertPermission('notifications/config/contacts');
Expand Down Expand Up @@ -71,7 +67,7 @@ public function indexAction(): void

if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) {
if ($searchBar->hasBeenSubmitted()) {
$filter = $this->getFilter();
$filter = QueryString::parse((string) $this->params);
} else {
$this->addControl($searchBar);
$this->sendMultipartUpdate();
Expand Down Expand Up @@ -161,7 +157,7 @@ public function addAction(): void
}
}
})
->on(Form::ON_SUCCESS, function (ContactGroupForm $form) {
->on(Form::ON_SUBMIT, function (ContactGroupForm $form) {
$groupIdentifier = $form->addGroup();

Notification::success($this->translate('New contact group has been successfully added'));
Expand Down Expand Up @@ -204,18 +200,4 @@ public function suggestMemberAction(): void

$this->getDocument()->addHtml($members);
}

/**
* Get the filter created from query string parameters
*
* @return Filter\Rule
*/
private function getFilter(): Filter\Rule
{
if ($this->filter === null) {
$this->filter = QueryString::parse((string) $this->params);
}

return $this->filter;
}
}
31 changes: 6 additions & 25 deletions application/controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
namespace Icinga\Module\Notifications\Controllers;

use Icinga\Module\Notifications\Common\ConfigurationTabs;
use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Common\Links;
use Icinga\Module\Notifications\Model\Channel;
use Icinga\Module\Notifications\Model\Contact;
use Icinga\Module\Notifications\View\ContactRenderer;
use Icinga\Module\Notifications\Web\Control\SearchBar\ObjectSuggestions;
use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Model\Contact;
use Icinga\Module\Notifications\Web\Form\ContactForm;
use Icinga\Module\Notifications\Widget\ItemList\ObjectList;
use Icinga\Web\Notification;
use ipl\Html\Contract\Form;
use ipl\Html\TemplateString;
use ipl\Sql\Connection;
use ipl\Sql\Expression;
use ipl\Stdlib\Filter;
use ipl\Web\Compat\CompatController;
use ipl\Web\Compat\SearchControls;
use ipl\Web\Control\LimitControl;
Expand All @@ -34,20 +33,16 @@ class ContactsController extends CompatController
use ConfigurationTabs;
use SearchControls;

/** @var Connection */
private $db;

/** @var Filter\Rule Filter from query string parameters */
private $filter;
private Connection $db;
Comment thread
sukhwinder33445 marked this conversation as resolved.

public function init()
public function init(): void
{
$this->assertPermission('notifications/config/contacts');

$this->db = Database::get();
}

public function indexAction()
public function indexAction(): void
{
$this->setTitle($this->translate('Contacts'));
$this->getTabs()->activate('contacts');
Expand All @@ -74,7 +69,7 @@ public function indexAction()

if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) {
if ($searchBar->hasBeenSubmitted()) {
$filter = $this->getFilter();
$filter = QueryString::parse((string) $this->params);
} else {
$this->addControl($searchBar);
$this->sendMultipartUpdate();
Expand Down Expand Up @@ -165,18 +160,4 @@ public function searchEditorAction(): void
$this->getDocument()->add($editor);
$this->setTitle($this->translate('Adjust Filter'));
}

/**
* Get the filter created from query string parameters
*
* @return Filter\Rule
*/
protected function getFilter(): Filter\Rule
{
if ($this->filter === null) {
$this->filter = QueryString::parse((string) $this->params);
}

return $this->filter;
}
}
2 changes: 1 addition & 1 deletion application/controllers/DaemonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function scriptAction(): void
->getBaseDir() . '/public/js';

$filePath = realpath($root . DIRECTORY_SEPARATOR . 'notifications-' . $fileName . $extension);
if ($filePath === false || substr($filePath, 0, strlen($root)) !== $root) {
if ($filePath === false || ! str_starts_with($filePath, $root)) {
if ($fileName === 'undefined') {
$this->httpNotFound(t("No file name submitted"));
}
Expand Down
11 changes: 7 additions & 4 deletions application/controllers/EventRuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Icinga\Application\Hook;
use Icinga\Application\Logger;
use Icinga\Exception\Http\HttpNotFoundException;
use Icinga\Exception\MissingParameterException;
use Icinga\Module\Notifications\Common\Auth;
use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Common\Links;
Expand All @@ -20,6 +21,7 @@
use Icinga\Module\Notifications\Web\Control\SearchBar\ExtraTagSuggestions;
use Icinga\Web\Notification;
use Icinga\Web\Session;
use ipl\Html\Attributes;
use ipl\Html\Contract\Form;
use ipl\Html\Html;
use ipl\Stdlib\Filter;
Expand All @@ -35,7 +37,6 @@ class EventRuleController extends CompatController
{
use Auth;

/** @var Session\SessionNamespace */
private Session\SessionNamespace $session;

public function init(): void
Expand All @@ -46,8 +47,8 @@ public function init(): void

public function indexAction(): void
{
$this->controls->addAttributes(['class' => 'event-rule-detail']);
$this->content->addAttributes(['class' => 'event-rule-detail']);
$this->controls->addAttributes(Attributes::create(['class' => 'event-rule-detail']));
$this->content->addAttributes(Attributes::create(['class' => 'event-rule-detail']));
$this->getTabs()->disableLegacyExtensions();

$ruleId = (int) $this->params->getRequired('id');
Expand Down Expand Up @@ -189,7 +190,7 @@ public function completeAction(): void
*
* @return void
*
* @throws \Icinga\Exception\MissingParameterException
* @throws MissingParameterException
*/
public function searchEditorAction(): void
{
Expand All @@ -206,6 +207,7 @@ public function searchEditorAction(): void
))
->first();
} elseif (isset($this->session->source)) {
/** @var ?Source $source */
$source = Source::on(Database::get())
->columns(['id', 'type'])
->filter(Filter::equal('id', $this->session->source))
Expand Down Expand Up @@ -323,6 +325,7 @@ public function editAction(): void
* @param int $ruleId
*
* @return Rule
*
* @throws HttpNotFoundException
*/
private function fetchRule(int $ruleId): Rule
Expand Down
Loading
Loading