From a0bb146790cc2c6b1615e8a50c6b19becd963250 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 18 Mar 2024 13:34:14 +0100 Subject: [PATCH 1/6] test: Command transmission fallback handling refs #950 --- test/php/Lib/StrikingCommandTransport.php | 28 +++++++++++ .../Transport/CommandTransportTest.php | 48 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 test/php/Lib/StrikingCommandTransport.php create mode 100644 test/php/library/Icingadb/Command/Transport/CommandTransportTest.php diff --git a/test/php/Lib/StrikingCommandTransport.php b/test/php/Lib/StrikingCommandTransport.php new file mode 100644 index 000000000..5e14ef9dd --- /dev/null +++ b/test/php/Lib/StrikingCommandTransport.php @@ -0,0 +1,28 @@ + ['host' => 'endpointA'], 'endpoint2' => ['host' => 'endpointB']]); + } + + public static function createTransport(ConfigObject $config): ApiCommandTransport + { + return (new class extends ApiCommandTransport { + protected function sendCommand(IcingaApiCommand $command) + { + throw new CommandTransportException(sprintf('%s strikes!', $this->getHost())); + } + })->setHost($config->host); + } +} diff --git a/test/php/library/Icingadb/Command/Transport/CommandTransportTest.php b/test/php/library/Icingadb/Command/Transport/CommandTransportTest.php new file mode 100644 index 000000000..63a1b6689 --- /dev/null +++ b/test/php/library/Icingadb/Command/Transport/CommandTransportTest.php @@ -0,0 +1,48 @@ +expectException(CommandTransportException::class); + $this->expectExceptionMessage('endpointB strikes!'); + + (new StrikingCommandTransport())->send( + (new AddCommentCommand()) + ->setExpireTime(42) + ->setAuthor('GLaDOS') + ->setComment('The cake is a lie') + ->setObjects(new \CallbackFilterIterator(new \ArrayIterator([ + (new Host())->setProperties(['name' => 'host1']), + (new Host())->setProperties(['name' => 'host2']), + ]), function ($host) { + return $host->name === 'host2'; + })) + ); + } + + public function testGeneratorsAreNotSupported() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Generators are not supported'); + + (new StrikingCommandTransport())->send( + (new AddCommentCommand()) + ->setExpireTime(42) + ->setAuthor('GLaDOS') + ->setComment('The cake is a lie') + ->setObjects((function () { + yield (new Host())->setProperties(['name' => 'host1']); + yield (new Host())->setProperties(['name' => 'host2']); + })()) + ); + } +} From 435a58b4f6c165ac330282de94f81166f9c523e0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 26 Mar 2024 16:11:01 +0100 Subject: [PATCH 2/6] CommandForm: Ensure `getCommands()` is passed an `Iterator` --- application/forms/Command/CommandForm.php | 18 ++++++++++++------ library/Icingadb/Common/CommandActions.php | 16 +++++++++++----- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/application/forms/Command/CommandForm.php b/application/forms/Command/CommandForm.php index a535c6d69..ce693ff09 100644 --- a/application/forms/Command/CommandForm.php +++ b/application/forms/Command/CommandForm.php @@ -5,8 +5,8 @@ namespace Icinga\Module\Icingadb\Forms\Command; use ArrayIterator; +use Countable; use Exception; -use Generator; use Icinga\Application\Logger; use Icinga\Module\Icingadb\Command\IcingaCommand; use Icinga\Module\Icingadb\Command\Transport\CommandTransport; @@ -16,6 +16,7 @@ use ipl\Html\Form; use ipl\Orm\Model; use ipl\Web\Common\CsrfCounterMeasure; +use IteratorIterator; use Traversable; abstract class CommandForm extends Form @@ -25,7 +26,7 @@ abstract class CommandForm extends Form protected $defaultAttributes = ['class' => 'icinga-form icinga-controls']; - /** @var mixed */ + /** @var (Traversable&Countable)|array */ protected $objects; /** @var bool */ @@ -43,7 +44,7 @@ abstract class CommandForm extends Form /** * Set the objects to issue the command for * - * @param mixed $objects A traversable that is also countable + * @param (Traversable&Countable)|array $objects A traversable that is also countable * * @return $this */ @@ -57,7 +58,7 @@ public function setObjects($objects): self /** * Get the objects to issue the command for * - * @return mixed + * @return (Traversable&Countable)|array */ public function getObjects() { @@ -123,10 +124,15 @@ protected function assemble() protected function onSuccess() { - $errors = []; $objects = $this->getObjects(); + if (is_array($objects)) { + $objects = new ArrayIterator($objects); + } else { + $objects = new IteratorIterator($objects); + } - foreach ($this->getCommands(is_array($objects) ? new ArrayIterator($objects) : $objects) as $command) { + $errors = []; + foreach ($this->getCommands($objects) as $command) { try { $this->sendCommand($command); } catch (Exception $e) { diff --git a/library/Icingadb/Common/CommandActions.php b/library/Icingadb/Common/CommandActions.php index ea5c2daf7..af7d19428 100644 --- a/library/Icingadb/Common/CommandActions.php +++ b/library/Icingadb/Common/CommandActions.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Icingadb\Common; +use Icinga\Exception\Http\HttpNotFoundException; use Icinga\Module\Icingadb\Forms\Command\CommandForm; use Icinga\Module\Icingadb\Forms\Command\Object\AcknowledgeProblemForm; use Icinga\Module\Icingadb\Forms\Command\Object\AddCommentForm; @@ -26,7 +27,7 @@ */ trait CommandActions { - /** @var Query $commandTargets */ + /** @var null|Query|array $commandTargets */ protected $commandTargets; /** @var Model $commandTargetModel */ @@ -51,14 +52,14 @@ protected function getFeatureStatus() /** * Fetch command targets * - * @return Query|Model[] + * @return Query|array */ abstract protected function fetchCommandTargets(); /** * Get command targets * - * @return Query|Model[] + * @return Query|array */ protected function getCommandTargets() { @@ -73,14 +74,19 @@ protected function getCommandTargets() * Get the model of the command targets * * @return Model + * @throws HttpNotFoundException If no command targets were found */ protected function getCommandTargetModel(): Model { if (! isset($this->commandTargetModel)) { $commandTargets = $this->getCommandTargets(); - if (is_array($commandTargets) && !empty($commandTargets)) { + if (empty($commandTargets) || count($commandTargets) === 0) { + throw new HttpNotFoundException('No command targets found'); + } + + if (is_array($commandTargets)) { $this->commandTargetModel = $commandTargets[0]; - } else { + } elseif ($commandTargets->count() > 0) { $this->commandTargetModel = $commandTargets->getModel(); } } From bcdbda1e40cc0b128b2e214fdd3694f06ee5abb4 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 26 Mar 2024 15:58:17 +0100 Subject: [PATCH 3/6] CommandForm: Expect `Iterator` in method `getCommands()` --- application/forms/Command/CommandForm.php | 5 +++-- .../forms/Command/Instance/ToggleInstanceFeaturesForm.php | 3 ++- application/forms/Command/Object/AcknowledgeProblemForm.php | 3 ++- application/forms/Command/Object/AddCommentForm.php | 3 ++- application/forms/Command/Object/CheckNowForm.php | 3 ++- application/forms/Command/Object/DeleteCommentForm.php | 3 ++- application/forms/Command/Object/DeleteDowntimeForm.php | 3 ++- application/forms/Command/Object/ProcessCheckResultForm.php | 3 ++- .../forms/Command/Object/RemoveAcknowledgementForm.php | 3 ++- application/forms/Command/Object/ScheduleCheckForm.php | 3 ++- .../forms/Command/Object/ScheduleHostDowntimeForm.php | 3 ++- .../forms/Command/Object/ScheduleServiceDowntimeForm.php | 3 ++- .../forms/Command/Object/SendCustomNotificationForm.php | 3 ++- .../forms/Command/Object/ToggleObjectFeaturesForm.php | 3 ++- 14 files changed, 29 insertions(+), 15 deletions(-) diff --git a/application/forms/Command/CommandForm.php b/application/forms/Command/CommandForm.php index ce693ff09..4dc99f1eb 100644 --- a/application/forms/Command/CommandForm.php +++ b/application/forms/Command/CommandForm.php @@ -16,6 +16,7 @@ use ipl\Html\Form; use ipl\Orm\Model; use ipl\Web\Common\CsrfCounterMeasure; +use Iterator; use IteratorIterator; use Traversable; @@ -106,11 +107,11 @@ abstract protected function assembleSubmitButton(); /** * Get the commands to issue for the given objects * - * @param Traversable $objects + * @param Iterator $objects * * @return Traversable */ - abstract protected function getCommands(Traversable $objects): Traversable; + abstract protected function getCommands(Iterator $objects): Traversable; protected function assemble() { diff --git a/application/forms/Command/Instance/ToggleInstanceFeaturesForm.php b/application/forms/Command/Instance/ToggleInstanceFeaturesForm.php index cf14db8a4..86c0bd195 100644 --- a/application/forms/Command/Instance/ToggleInstanceFeaturesForm.php +++ b/application/forms/Command/Instance/ToggleInstanceFeaturesForm.php @@ -8,6 +8,7 @@ use Icinga\Module\Icingadb\Forms\Command\CommandForm; use Icinga\Web\Notification; use ipl\Web\FormDecorator\IcingaFormDecorator; +use Iterator; use Traversable; class ToggleInstanceFeaturesForm extends CommandForm @@ -133,7 +134,7 @@ protected function assembleSubmitButton() { } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { foreach ($this->features as $feature => $spec) { $featureState = $this->getElement($feature)->isChecked(); diff --git a/application/forms/Command/Object/AcknowledgeProblemForm.php b/application/forms/Command/Object/AcknowledgeProblemForm.php index 81b93e2e7..7497ed9b8 100644 --- a/application/forms/Command/Object/AcknowledgeProblemForm.php +++ b/application/forms/Command/Object/AcknowledgeProblemForm.php @@ -17,6 +17,7 @@ use ipl\Validator\CallbackValidator; use ipl\Web\FormDecorator\IcingaFormDecorator; use ipl\Web\Widget\Icon; +use Iterator; use Traversable; use function ipl\Stdlib\iterable_value_first; @@ -186,7 +187,7 @@ protected function assembleSubmitButton() (new IcingaFormDecorator())->decorate($this->getElement('btn_submit')); } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { $granted = $this->filterGrantedOn('icingadb/command/acknowledge-problem', $objects); diff --git a/application/forms/Command/Object/AddCommentForm.php b/application/forms/Command/Object/AddCommentForm.php index 9cd0754b7..9ab6fbeaf 100644 --- a/application/forms/Command/Object/AddCommentForm.php +++ b/application/forms/Command/Object/AddCommentForm.php @@ -17,6 +17,7 @@ use ipl\Validator\CallbackValidator; use ipl\Web\FormDecorator\IcingaFormDecorator; use ipl\Web\Widget\Icon; +use Iterator; use Traversable; use function ipl\Stdlib\iterable_value_first; @@ -141,7 +142,7 @@ protected function assembleSubmitButton() (new IcingaFormDecorator())->decorate($this->getElement('btn_submit')); } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { $granted = $this->filterGrantedOn('icingadb/command/comment/add', $objects); diff --git a/application/forms/Command/Object/CheckNowForm.php b/application/forms/Command/Object/CheckNowForm.php index b7a506ce7..a5cdd0c6b 100644 --- a/application/forms/Command/Object/CheckNowForm.php +++ b/application/forms/Command/Object/CheckNowForm.php @@ -9,6 +9,7 @@ use Icinga\Module\Icingadb\Forms\Command\CommandForm; use Icinga\Web\Notification; use ipl\Web\Widget\Icon; +use Iterator; use Traversable; class CheckNowForm extends CommandForm @@ -44,7 +45,7 @@ protected function assembleSubmitButton() ); } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { $granted = (function () use ($objects): Generator { foreach ($objects as $object) { diff --git a/application/forms/Command/Object/DeleteCommentForm.php b/application/forms/Command/Object/DeleteCommentForm.php index 25275baf2..000e9691b 100644 --- a/application/forms/Command/Object/DeleteCommentForm.php +++ b/application/forms/Command/Object/DeleteCommentForm.php @@ -10,6 +10,7 @@ use Icinga\Web\Notification; use ipl\Web\Common\RedirectOption; use ipl\Web\Widget\Icon; +use Iterator; use Traversable; class DeleteCommentForm extends CommandForm @@ -54,7 +55,7 @@ protected function assembleSubmitButton() ); } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { $granted = (function () use ($objects): Generator { foreach ($objects as $object) { diff --git a/application/forms/Command/Object/DeleteDowntimeForm.php b/application/forms/Command/Object/DeleteDowntimeForm.php index 5f695b962..24676d7be 100644 --- a/application/forms/Command/Object/DeleteDowntimeForm.php +++ b/application/forms/Command/Object/DeleteDowntimeForm.php @@ -10,6 +10,7 @@ use Icinga\Web\Notification; use ipl\Web\Common\RedirectOption; use ipl\Web\Widget\Icon; +use Iterator; use Traversable; class DeleteDowntimeForm extends CommandForm @@ -66,7 +67,7 @@ protected function assembleSubmitButton() ); } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { $granted = (function () use ($objects): Generator { foreach ($objects as $object) { diff --git a/application/forms/Command/Object/ProcessCheckResultForm.php b/application/forms/Command/Object/ProcessCheckResultForm.php index 5764bf846..547a69461 100644 --- a/application/forms/Command/Object/ProcessCheckResultForm.php +++ b/application/forms/Command/Object/ProcessCheckResultForm.php @@ -15,6 +15,7 @@ use ipl\Orm\Model; use ipl\Web\FormDecorator\IcingaFormDecorator; use ipl\Web\Widget\Icon; +use Iterator; use Traversable; use function ipl\Stdlib\iterable_value_first; @@ -133,7 +134,7 @@ protected function assembleSubmitButton() (new IcingaFormDecorator())->decorate($this->getElement('btn_submit')); } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { $granted = (function () use ($objects): Generator { foreach ($this->filterGrantedOn('icingadb/command/process-check-result', $objects) as $object) { diff --git a/application/forms/Command/Object/RemoveAcknowledgementForm.php b/application/forms/Command/Object/RemoveAcknowledgementForm.php index 8697985ff..fddb3974a 100644 --- a/application/forms/Command/Object/RemoveAcknowledgementForm.php +++ b/application/forms/Command/Object/RemoveAcknowledgementForm.php @@ -9,6 +9,7 @@ use Icinga\Module\Icingadb\Model\Host; use Icinga\Web\Notification; use ipl\Web\Widget\Icon; +use Iterator; use Traversable; use function ipl\Stdlib\iterable_value_first; @@ -62,7 +63,7 @@ protected function assembleSubmitButton() ); } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { $granted = $this->filterGrantedOn('icingadb/command/remove-acknowledgement', $objects); diff --git a/application/forms/Command/Object/ScheduleCheckForm.php b/application/forms/Command/Object/ScheduleCheckForm.php index 9b32ea1a0..5b82551af 100644 --- a/application/forms/Command/Object/ScheduleCheckForm.php +++ b/application/forms/Command/Object/ScheduleCheckForm.php @@ -16,6 +16,7 @@ use ipl\Html\Text; use ipl\Web\FormDecorator\IcingaFormDecorator; use ipl\Web\Widget\Icon; +use Iterator; use Traversable; use function ipl\Stdlib\iterable_value_first; @@ -109,7 +110,7 @@ protected function assembleSubmitButton() (new IcingaFormDecorator())->decorate($this->getElement('btn_submit')); } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { $granted = (function () use ($objects): Generator { foreach ($objects as $object) { diff --git a/application/forms/Command/Object/ScheduleHostDowntimeForm.php b/application/forms/Command/Object/ScheduleHostDowntimeForm.php index bc211143f..1de3cc383 100644 --- a/application/forms/Command/Object/ScheduleHostDowntimeForm.php +++ b/application/forms/Command/Object/ScheduleHostDowntimeForm.php @@ -11,6 +11,7 @@ use Icinga\Module\Icingadb\Command\Object\ScheduleHostDowntimeCommand; use Icinga\Web\Notification; use ipl\Web\FormDecorator\IcingaFormDecorator; +use Iterator; use Traversable; class ScheduleHostDowntimeForm extends ScheduleServiceDowntimeForm @@ -87,7 +88,7 @@ protected function assembleElements() $decorator->decorate($this->getElement('child_options')); } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { $granted = $this->filterGrantedOn('icingadb/command/downtime/schedule', $objects); diff --git a/application/forms/Command/Object/ScheduleServiceDowntimeForm.php b/application/forms/Command/Object/ScheduleServiceDowntimeForm.php index 184a4e8bf..30816be8e 100644 --- a/application/forms/Command/Object/ScheduleServiceDowntimeForm.php +++ b/application/forms/Command/Object/ScheduleServiceDowntimeForm.php @@ -16,6 +16,7 @@ use ipl\Validator\CallbackValidator; use ipl\Web\FormDecorator\IcingaFormDecorator; use ipl\Web\Widget\Icon; +use Iterator; use Traversable; class ScheduleServiceDowntimeForm extends CommandForm @@ -242,7 +243,7 @@ protected function assembleSubmitButton() (new IcingaFormDecorator())->decorate($this->getElement('btn_submit')); } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { $granted = $this->filterGrantedOn('icingadb/command/downtime/schedule', $objects); diff --git a/application/forms/Command/Object/SendCustomNotificationForm.php b/application/forms/Command/Object/SendCustomNotificationForm.php index dfb1e9630..040e4bd77 100644 --- a/application/forms/Command/Object/SendCustomNotificationForm.php +++ b/application/forms/Command/Object/SendCustomNotificationForm.php @@ -14,6 +14,7 @@ use ipl\Html\Text; use ipl\Web\FormDecorator\IcingaFormDecorator; use ipl\Web\Widget\Icon; +use Iterator; use Traversable; use function ipl\Stdlib\iterable_value_first; @@ -108,7 +109,7 @@ protected function assembleSubmitButton() (new IcingaFormDecorator())->decorate($this->getElement('btn_submit')); } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { $granted = $this->filterGrantedOn('icingadb/command/send-custom-notification', $objects); diff --git a/application/forms/Command/Object/ToggleObjectFeaturesForm.php b/application/forms/Command/Object/ToggleObjectFeaturesForm.php index 50767da70..f0b8c0c03 100644 --- a/application/forms/Command/Object/ToggleObjectFeaturesForm.php +++ b/application/forms/Command/Object/ToggleObjectFeaturesForm.php @@ -10,6 +10,7 @@ use ipl\Html\FormElement\CheckboxElement; use ipl\Orm\Model; use ipl\Web\FormDecorator\IcingaFormDecorator; +use Iterator; use Traversable; class ToggleObjectFeaturesForm extends CommandForm @@ -156,7 +157,7 @@ protected function assembleSubmitButton() { } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { foreach ($this->features as $feature => $spec) { if ($this->getElement($feature) instanceof CheckboxElement) { From d5b4087a50e73eb01868da51712bd876af472923 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 26 Mar 2024 16:13:58 +0100 Subject: [PATCH 4/6] CommandForm: Don't pass generators to commands --- application/forms/Command/CommandForm.php | 17 ------------- .../Command/Object/AcknowledgeProblemForm.php | 7 +++++- .../forms/Command/Object/AddCommentForm.php | 7 +++++- .../forms/Command/Object/CheckNowForm.php | 24 ++++++++----------- .../Command/Object/DeleteCommentForm.php | 14 +++++------ .../Command/Object/DeleteDowntimeForm.php | 18 ++++++-------- .../Command/Object/ProcessCheckResultForm.php | 14 +++++------ .../Object/RemoveAcknowledgementForm.php | 7 +++++- .../Command/Object/ScheduleCheckForm.php | 24 ++++++++----------- .../Object/ScheduleHostDowntimeForm.php | 7 +++++- .../Object/ScheduleServiceDowntimeForm.php | 7 +++++- .../Object/SendCustomNotificationForm.php | 7 +++++- .../Object/ToggleObjectFeaturesForm.php | 6 ++++- 13 files changed, 80 insertions(+), 79 deletions(-) diff --git a/application/forms/Command/CommandForm.php b/application/forms/Command/CommandForm.php index 4dc99f1eb..49a05657f 100644 --- a/application/forms/Command/CommandForm.php +++ b/application/forms/Command/CommandForm.php @@ -166,21 +166,4 @@ protected function sendCommand(IcingaCommand $command) { (new CommandTransport())->send($command); } - - /** - * Yield the $objects the currently logged in user has the permission $permission for - * - * @param string $permission - * @param Traversable $objects - * - * @return Generator - */ - protected function filterGrantedOn(string $permission, Traversable $objects): Generator - { - foreach ($objects as $object) { - if ($this->isGrantedOn($permission, $object)) { - yield $object; - } - } - } } diff --git a/application/forms/Command/Object/AcknowledgeProblemForm.php b/application/forms/Command/Object/AcknowledgeProblemForm.php index 7497ed9b8..f5e792324 100644 --- a/application/forms/Command/Object/AcknowledgeProblemForm.php +++ b/application/forms/Command/Object/AcknowledgeProblemForm.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; +use CallbackFilterIterator; use DateInterval; use DateTime; use Icinga\Application\Config; @@ -14,6 +15,7 @@ use ipl\Html\Attributes; use ipl\Html\HtmlElement; use ipl\Html\Text; +use ipl\Orm\Model; use ipl\Validator\CallbackValidator; use ipl\Web\FormDecorator\IcingaFormDecorator; use ipl\Web\Widget\Icon; @@ -189,8 +191,11 @@ protected function assembleSubmitButton() protected function getCommands(Iterator $objects): Traversable { - $granted = $this->filterGrantedOn('icingadb/command/acknowledge-problem', $objects); + $granted = new CallbackFilterIterator($objects, function (Model $object): bool { + return $this->isGrantedOn('icingadb/command/acknowledge-problem', $object); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { $command = new AcknowledgeProblemCommand(); $command->setObjects($granted); diff --git a/application/forms/Command/Object/AddCommentForm.php b/application/forms/Command/Object/AddCommentForm.php index 9ab6fbeaf..e991e84ff 100644 --- a/application/forms/Command/Object/AddCommentForm.php +++ b/application/forms/Command/Object/AddCommentForm.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; +use CallbackFilterIterator; use DateInterval; use DateTime; use Icinga\Application\Config; @@ -14,6 +15,7 @@ use ipl\Html\Attributes; use ipl\Html\HtmlElement; use ipl\Html\Text; +use ipl\Orm\Model; use ipl\Validator\CallbackValidator; use ipl\Web\FormDecorator\IcingaFormDecorator; use ipl\Web\Widget\Icon; @@ -144,8 +146,11 @@ protected function assembleSubmitButton() protected function getCommands(Iterator $objects): Traversable { - $granted = $this->filterGrantedOn('icingadb/command/comment/add', $objects); + $granted = new CallbackFilterIterator($objects, function (Model $object): bool { + return $this->isGrantedOn('icingadb/command/comment/add', $object); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { $command = new AddCommentCommand(); $command->setObjects($granted); diff --git a/application/forms/Command/Object/CheckNowForm.php b/application/forms/Command/Object/CheckNowForm.php index a5cdd0c6b..eb1e03ba0 100644 --- a/application/forms/Command/Object/CheckNowForm.php +++ b/application/forms/Command/Object/CheckNowForm.php @@ -4,10 +4,11 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; -use Generator; +use CallbackFilterIterator; use Icinga\Module\Icingadb\Command\Object\ScheduleCheckCommand; use Icinga\Module\Icingadb\Forms\Command\CommandForm; use Icinga\Web\Notification; +use ipl\Orm\Model; use ipl\Web\Widget\Icon; use Iterator; use Traversable; @@ -47,20 +48,15 @@ protected function assembleSubmitButton() protected function getCommands(Iterator $objects): Traversable { - $granted = (function () use ($objects): Generator { - foreach ($objects as $object) { - if ( - $this->isGrantedOn('icingadb/command/schedule-check', $object) - || ( - $object->active_checks_enabled - && $this->isGrantedOn('icingadb/command/schedule-check/active-only', $object) - ) - ) { - yield $object; - } - } - })(); + $granted = new CallbackFilterIterator($objects, function (Model $object): bool { + return $this->isGrantedOn('icingadb/command/schedule-check', $object) + || ( + $object->active_checks_enabled + && $this->isGrantedOn('icingadb/command/schedule-check/active-only', $object) + ); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { $command = new ScheduleCheckCommand(); $command->setObjects($granted); diff --git a/application/forms/Command/Object/DeleteCommentForm.php b/application/forms/Command/Object/DeleteCommentForm.php index 000e9691b..a35fc2e5f 100644 --- a/application/forms/Command/Object/DeleteCommentForm.php +++ b/application/forms/Command/Object/DeleteCommentForm.php @@ -4,10 +4,11 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; -use Generator; +use CallbackFilterIterator; use Icinga\Module\Icingadb\Command\Object\DeleteCommentCommand; use Icinga\Module\Icingadb\Forms\Command\CommandForm; use Icinga\Web\Notification; +use ipl\Orm\Model; use ipl\Web\Common\RedirectOption; use ipl\Web\Widget\Icon; use Iterator; @@ -57,14 +58,11 @@ protected function assembleSubmitButton() protected function getCommands(Iterator $objects): Traversable { - $granted = (function () use ($objects): Generator { - foreach ($objects as $object) { - if ($this->isGrantedOn('icingadb/command/comment/delete', $object->{$object->object_type})) { - yield $object; - } - } - })(); + $granted = new CallbackFilterIterator($objects, function (Model $object): bool { + return $this->isGrantedOn('icingadb/command/comment/delete', $object->{$object->object_type}); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { $command = new DeleteCommentCommand(); $command->setObjects($granted); diff --git a/application/forms/Command/Object/DeleteDowntimeForm.php b/application/forms/Command/Object/DeleteDowntimeForm.php index 24676d7be..b13bcc524 100644 --- a/application/forms/Command/Object/DeleteDowntimeForm.php +++ b/application/forms/Command/Object/DeleteDowntimeForm.php @@ -4,10 +4,11 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; -use Generator; +use CallbackFilterIterator; use Icinga\Module\Icingadb\Command\Object\DeleteDowntimeCommand; use Icinga\Module\Icingadb\Forms\Command\CommandForm; use Icinga\Web\Notification; +use ipl\Orm\Model; use ipl\Web\Common\RedirectOption; use ipl\Web\Widget\Icon; use Iterator; @@ -69,17 +70,12 @@ protected function assembleSubmitButton() protected function getCommands(Iterator $objects): Traversable { - $granted = (function () use ($objects): Generator { - foreach ($objects as $object) { - if ( - $this->isGrantedOn('icingadb/command/downtime/delete', $object->{$object->object_type}) - && $object->scheduled_by === null - ) { - yield $object; - } - } - })(); + $granted = new CallbackFilterIterator($objects, function (Model $object): bool { + return $object->scheduled_by === null + && $this->isGrantedOn('icingadb/command/downtime/delete', $object->{$object->object_type}); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { $command = new DeleteDowntimeCommand(); $command->setObjects($granted); diff --git a/application/forms/Command/Object/ProcessCheckResultForm.php b/application/forms/Command/Object/ProcessCheckResultForm.php index 547a69461..7c612bfaa 100644 --- a/application/forms/Command/Object/ProcessCheckResultForm.php +++ b/application/forms/Command/Object/ProcessCheckResultForm.php @@ -4,7 +4,7 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; -use Generator; +use CallbackFilterIterator; use Icinga\Module\Icingadb\Command\Object\ProcessCheckResultCommand; use Icinga\Module\Icingadb\Forms\Command\CommandForm; use Icinga\Module\Icingadb\Model\Host; @@ -136,14 +136,12 @@ protected function assembleSubmitButton() protected function getCommands(Iterator $objects): Traversable { - $granted = (function () use ($objects): Generator { - foreach ($this->filterGrantedOn('icingadb/command/process-check-result', $objects) as $object) { - if ($object->passive_checks_enabled) { - yield $object; - } - } - })(); + $granted = new CallbackFilterIterator($objects, function (Model $object): bool { + return $object->passive_checks_enabled + && $this->isGrantedOn('icingadb/command/process-check-result', $object); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { $command = new ProcessCheckResultCommand(); $command->setObjects($granted); diff --git a/application/forms/Command/Object/RemoveAcknowledgementForm.php b/application/forms/Command/Object/RemoveAcknowledgementForm.php index fddb3974a..d81fe7f93 100644 --- a/application/forms/Command/Object/RemoveAcknowledgementForm.php +++ b/application/forms/Command/Object/RemoveAcknowledgementForm.php @@ -4,10 +4,12 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; +use CallbackFilterIterator; use Icinga\Module\Icingadb\Command\Object\RemoveAcknowledgementCommand; use Icinga\Module\Icingadb\Forms\Command\CommandForm; use Icinga\Module\Icingadb\Model\Host; use Icinga\Web\Notification; +use ipl\Orm\Model; use ipl\Web\Widget\Icon; use Iterator; use Traversable; @@ -65,8 +67,11 @@ protected function assembleSubmitButton() protected function getCommands(Iterator $objects): Traversable { - $granted = $this->filterGrantedOn('icingadb/command/remove-acknowledgement', $objects); + $granted = new CallbackFilterIterator($objects, function (Model $object): bool { + return $this->isGrantedOn('icingadb/command/remove-acknowledgement', $object); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { $command = new RemoveAcknowledgementCommand(); $command->setObjects($granted); diff --git a/application/forms/Command/Object/ScheduleCheckForm.php b/application/forms/Command/Object/ScheduleCheckForm.php index 5b82551af..bdeba53cb 100644 --- a/application/forms/Command/Object/ScheduleCheckForm.php +++ b/application/forms/Command/Object/ScheduleCheckForm.php @@ -4,9 +4,9 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; +use CallbackFilterIterator; use DateInterval; use DateTime; -use Generator; use Icinga\Module\Icingadb\Command\Object\ScheduleCheckCommand; use Icinga\Module\Icingadb\Forms\Command\CommandForm; use Icinga\Module\Icingadb\Model\Host; @@ -14,6 +14,7 @@ use ipl\Html\Attributes; use ipl\Html\HtmlElement; use ipl\Html\Text; +use ipl\Orm\Model; use ipl\Web\FormDecorator\IcingaFormDecorator; use ipl\Web\Widget\Icon; use Iterator; @@ -112,20 +113,15 @@ protected function assembleSubmitButton() protected function getCommands(Iterator $objects): Traversable { - $granted = (function () use ($objects): Generator { - foreach ($objects as $object) { - if ( - $this->isGrantedOn('icingadb/command/schedule-check', $object) - || ( - $object->active_checks_enabled - && $this->isGrantedOn('icingadb/command/schedule-check/active-only', $object) - ) - ) { - yield $object; - } - } - })(); + $granted = new CallbackFilterIterator($objects, function (Model $object): bool { + return $this->isGrantedOn('icingadb/command/schedule-check', $object) + || ( + $object->active_checks_enabled + && $this->isGrantedOn('icingadb/command/schedule-check/active-only', $object) + ); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { $command = new ScheduleCheckCommand(); $command->setObjects($granted); diff --git a/application/forms/Command/Object/ScheduleHostDowntimeForm.php b/application/forms/Command/Object/ScheduleHostDowntimeForm.php index 1de3cc383..a09b00d82 100644 --- a/application/forms/Command/Object/ScheduleHostDowntimeForm.php +++ b/application/forms/Command/Object/ScheduleHostDowntimeForm.php @@ -4,12 +4,14 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; +use CallbackFilterIterator; use DateInterval; use DateTime; use Icinga\Application\Config; use Icinga\Module\Icingadb\Command\Object\PropagateHostDowntimeCommand; use Icinga\Module\Icingadb\Command\Object\ScheduleHostDowntimeCommand; use Icinga\Web\Notification; +use ipl\Orm\Model; use ipl\Web\FormDecorator\IcingaFormDecorator; use Iterator; use Traversable; @@ -90,8 +92,11 @@ protected function assembleElements() protected function getCommands(Iterator $objects): Traversable { - $granted = $this->filterGrantedOn('icingadb/command/downtime/schedule', $objects); + $granted = new CallbackFilterIterator($objects, function (Model $object): bool { + return $this->isGrantedOn('icingadb/command/downtime/schedule', $object); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { if (($childOptions = (int) $this->getValue('child_options'))) { $command = new PropagateHostDowntimeCommand(); diff --git a/application/forms/Command/Object/ScheduleServiceDowntimeForm.php b/application/forms/Command/Object/ScheduleServiceDowntimeForm.php index 30816be8e..b237408ae 100644 --- a/application/forms/Command/Object/ScheduleServiceDowntimeForm.php +++ b/application/forms/Command/Object/ScheduleServiceDowntimeForm.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; +use CallbackFilterIterator; use DateInterval; use DateTime; use Icinga\Application\Config; @@ -13,6 +14,7 @@ use ipl\Html\Attributes; use ipl\Html\HtmlElement; use ipl\Html\Text; +use ipl\Orm\Model; use ipl\Validator\CallbackValidator; use ipl\Web\FormDecorator\IcingaFormDecorator; use ipl\Web\Widget\Icon; @@ -245,8 +247,11 @@ protected function assembleSubmitButton() protected function getCommands(Iterator $objects): Traversable { - $granted = $this->filterGrantedOn('icingadb/command/downtime/schedule', $objects); + $granted = new CallbackFilterIterator($objects, function (Model $object): bool { + return $this->isGrantedOn('icingadb/command/downtime/schedule', $object); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { $command = new ScheduleServiceDowntimeCommand(); $command->setObjects($granted); diff --git a/application/forms/Command/Object/SendCustomNotificationForm.php b/application/forms/Command/Object/SendCustomNotificationForm.php index 040e4bd77..4b0539e03 100644 --- a/application/forms/Command/Object/SendCustomNotificationForm.php +++ b/application/forms/Command/Object/SendCustomNotificationForm.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; +use CallbackFilterIterator; use Icinga\Application\Config; use Icinga\Module\Icingadb\Command\Object\SendCustomNotificationCommand; use Icinga\Module\Icingadb\Forms\Command\CommandForm; @@ -12,6 +13,7 @@ use ipl\Html\Attributes; use ipl\Html\HtmlElement; use ipl\Html\Text; +use ipl\Orm\Model; use ipl\Web\FormDecorator\IcingaFormDecorator; use ipl\Web\Widget\Icon; use Iterator; @@ -111,8 +113,11 @@ protected function assembleSubmitButton() protected function getCommands(Iterator $objects): Traversable { - $granted = $this->filterGrantedOn('icingadb/command/send-custom-notification', $objects); + $granted = new CallbackFilterIterator($objects, function (Model $object): bool { + return $this->isGrantedOn('icingadb/command/send-custom-notification', $object); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { $command = new SendCustomNotificationCommand(); $command->setObjects($granted); diff --git a/application/forms/Command/Object/ToggleObjectFeaturesForm.php b/application/forms/Command/Object/ToggleObjectFeaturesForm.php index f0b8c0c03..63530f6a2 100644 --- a/application/forms/Command/Object/ToggleObjectFeaturesForm.php +++ b/application/forms/Command/Object/ToggleObjectFeaturesForm.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; +use CallbackFilterIterator; use Icinga\Module\Icingadb\Command\Object\ToggleObjectFeatureCommand; use Icinga\Module\Icingadb\Forms\Command\CommandForm; use Icinga\Web\Notification; @@ -170,8 +171,11 @@ protected function getCommands(Iterator $objects): Traversable continue; } - $granted = $this->filterGrantedOn($spec['permission'], $objects); + $granted = new CallbackFilterIterator($objects, function (Model $object) use ($spec): bool { + return $this->isGrantedOn($spec['permission'], $object); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { $command = new ToggleObjectFeatureCommand(); $command->setObjects($granted); From ac6273be73b3d8a0d7680247b00e1b82def08f7a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 26 Mar 2024 16:15:06 +0100 Subject: [PATCH 5/6] ObjectsCommand: Don't accept generators anymore --- library/Icingadb/Command/Object/ObjectsCommand.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/library/Icingadb/Command/Object/ObjectsCommand.php b/library/Icingadb/Command/Object/ObjectsCommand.php index 3de6c83b6..f1a50d7ec 100644 --- a/library/Icingadb/Command/Object/ObjectsCommand.php +++ b/library/Icingadb/Command/Object/ObjectsCommand.php @@ -5,8 +5,11 @@ namespace Icinga\Module\Icingadb\Command\Object; use ArrayIterator; +use Generator; use Icinga\Module\Icingadb\Command\IcingaCommand; +use InvalidArgumentException; use ipl\Orm\Model; +use LogicException; use Traversable; /** @@ -24,12 +27,18 @@ abstract class ObjectsCommand extends IcingaCommand /** * Set the involved objects * - * @param Traversable $objects + * @param Traversable $objects Except generators * * @return $this + * + * @throws InvalidArgumentException If a generator is passed */ public function setObjects(Traversable $objects): self { + if ($objects instanceof Generator) { + throw new InvalidArgumentException('Generators are not supported'); + } + $this->objects = $objects; return $this; @@ -57,7 +66,7 @@ public function setObject(Model $object): self public function getObjects(): Traversable { if ($this->objects === null) { - throw new \LogicException( + throw new LogicException( 'You are accessing an unset property. Please make sure to set it beforehand.' ); } From e924ab87641c50ba4cdd7270959d9ef5ac3245a2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 26 Mar 2024 16:16:25 +0100 Subject: [PATCH 6/6] phpstan: Update baselines --- .../Widget/Detail/MultiselectQuickActions.php | 1 + phpstan-baseline-7x.neon | 60 +--------- phpstan-baseline-8x.neon | 60 +--------- phpstan-baseline-standard.neon | 110 ------------------ 4 files changed, 11 insertions(+), 220 deletions(-) diff --git a/library/Icingadb/Widget/Detail/MultiselectQuickActions.php b/library/Icingadb/Widget/Detail/MultiselectQuickActions.php index f398d80e5..b80ec9df2 100644 --- a/library/Icingadb/Widget/Detail/MultiselectQuickActions.php +++ b/library/Icingadb/Widget/Detail/MultiselectQuickActions.php @@ -67,6 +67,7 @@ protected function assemble() ) { $removeAckForm = (new RemoveAcknowledgementForm()) ->setAction($this->getLink('removeAcknowledgement')) + // TODO: This is a hack as for the button label the count of objects is used. setCount? setMultiple? ->setObjects(array_fill(0, $this->summary->$acks, null)); $this->add(Html::tag('li', $removeAckForm)); diff --git a/phpstan-baseline-7x.neon b/phpstan-baseline-7x.neon index e8d2562f2..6da352556 100644 --- a/phpstan-baseline-7x.neon +++ b/phpstan-baseline-7x.neon @@ -5,61 +5,6 @@ parameters: count: 1 path: application/controllers/EventController.php - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/AcknowledgeProblemForm.php - - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/AddCommentForm.php - - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" - count: 1 - path: application/forms/Command/Object/CheckNowForm.php - - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/DeleteCommentForm.php - - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/DeleteDowntimeForm.php - - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/ProcessCheckResultForm.php - - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/RemoveAcknowledgementForm.php - - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/ScheduleCheckForm.php - - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" - count: 1 - path: application/forms/Command/Object/ScheduleHostDowntimeForm.php - - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/ScheduleServiceDowntimeForm.php - - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/SendCustomNotificationForm.php - - message: "#^Parameter \\#1 \\$str of function md5 expects string, mixed given\\.$#" count: 1 @@ -164,3 +109,8 @@ parameters: message: "#^Parameter \\#2 \\$str of function explode expects string, mixed given\\.$#" count: 1 path: library/Icingadb/Web/Controller.php + + - + message: "#^Parameter \\#1 \\$objects of method Icinga\\\\Module\\\\Icingadb\\\\Forms\\\\Command\\\\CommandForm\\:\\:setObjects\\(\\) expects array\\\\|\\(Countable&Traversable\\\\), array\\\\|false given\\.$#" + count: 1 + path: library/Icingadb/Widget/Detail/MultiselectQuickActions.php diff --git a/phpstan-baseline-8x.neon b/phpstan-baseline-8x.neon index 2cea59701..b5b85f7f9 100644 --- a/phpstan-baseline-8x.neon +++ b/phpstan-baseline-8x.neon @@ -5,61 +5,6 @@ parameters: count: 1 path: application/controllers/EventController.php - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/AcknowledgeProblemForm.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/AddCommentForm.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 1 - path: application/forms/Command/Object/CheckNowForm.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/DeleteCommentForm.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/DeleteDowntimeForm.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/ProcessCheckResultForm.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/RemoveAcknowledgementForm.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/ScheduleCheckForm.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 1 - path: application/forms/Command/Object/ScheduleHostDowntimeForm.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/ScheduleServiceDowntimeForm.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/SendCustomNotificationForm.php - - message: "#^Parameter \\#1 \\$string of function md5 expects string, mixed given\\.$#" count: 1 @@ -159,3 +104,8 @@ parameters: message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#" count: 1 path: library/Icingadb/Web/Controller.php + + - + message: "#^Parameter \\#1 \\$objects of method Icinga\\\\Module\\\\Icingadb\\\\Forms\\\\Command\\\\CommandForm\\:\\:setObjects\\(\\) expects array\\\\|\\(Countable&Traversable\\\\), array\\ given\\.$#" + count: 1 + path: library/Icingadb/Widget/Detail/MultiselectQuickActions.php diff --git a/phpstan-baseline-standard.neon b/phpstan-baseline-standard.neon index 70fd385d2..5d23e8296 100644 --- a/phpstan-baseline-standard.neon +++ b/phpstan-baseline-standard.neon @@ -120,16 +120,6 @@ parameters: count: 1 path: application/controllers/CommentController.php - - - message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\CommentController\\:\\:\\$commandTargets \\(ipl\\\\Orm\\\\Query\\) does not accept array\\.$#" - count: 1 - path: application/controllers/CommentController.php - - - - message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\CommentController\\:\\:\\$commandTargets \\(ipl\\\\Orm\\\\Query\\) in isset\\(\\) is not nullable\\.$#" - count: 1 - path: application/controllers/CommentController.php - - message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\CommentController\\:\\:\\$comment \\(Icinga\\\\Module\\\\Icingadb\\\\Model\\\\Comment\\) does not accept ipl\\\\Orm\\\\Model\\.$#" count: 1 @@ -260,16 +250,6 @@ parameters: count: 1 path: application/controllers/DowntimeController.php - - - message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\DowntimeController\\:\\:\\$commandTargets \\(ipl\\\\Orm\\\\Query\\) does not accept array\\.$#" - count: 1 - path: application/controllers/DowntimeController.php - - - - message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\DowntimeController\\:\\:\\$commandTargets \\(ipl\\\\Orm\\\\Query\\) in isset\\(\\) is not nullable\\.$#" - count: 1 - path: application/controllers/DowntimeController.php - - message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\DowntimeController\\:\\:\\$downtime \\(Icinga\\\\Module\\\\Icingadb\\\\Model\\\\Downtime\\) does not accept ipl\\\\Orm\\\\Model\\.$#" count: 1 @@ -525,16 +505,6 @@ parameters: count: 1 path: application/controllers/HostController.php - - - message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\HostController\\:\\:\\$commandTargets \\(ipl\\\\Orm\\\\Query\\) does not accept array\\.$#" - count: 1 - path: application/controllers/HostController.php - - - - message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\HostController\\:\\:\\$commandTargets \\(ipl\\\\Orm\\\\Query\\) in isset\\(\\) is not nullable\\.$#" - count: 1 - path: application/controllers/HostController.php - - message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\HostgroupController\\:\\:indexAction\\(\\) has no return type specified\\.$#" count: 1 @@ -695,11 +665,6 @@ parameters: count: 1 path: application/controllers/HostsController.php - - - message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\HostsController\\:\\:\\$commandTargets \\(ipl\\\\Orm\\\\Query\\) in isset\\(\\) is not nullable\\.$#" - count: 1 - path: application/controllers/HostsController.php - - message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\MigrateController\\:\\:backendSupportAction\\(\\) has no return type specified\\.$#" count: 1 @@ -920,16 +885,6 @@ parameters: count: 1 path: application/controllers/ServiceController.php - - - message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\ServiceController\\:\\:\\$commandTargets \\(ipl\\\\Orm\\\\Query\\) does not accept array\\.$#" - count: 1 - path: application/controllers/ServiceController.php - - - - message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\ServiceController\\:\\:\\$commandTargets \\(ipl\\\\Orm\\\\Query\\) in isset\\(\\) is not nullable\\.$#" - count: 1 - path: application/controllers/ServiceController.php - - message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\ServicegroupController\\:\\:indexAction\\(\\) has no return type specified\\.$#" count: 1 @@ -1130,11 +1085,6 @@ parameters: count: 1 path: application/controllers/ServicesController.php - - - message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\ServicesController\\:\\:\\$commandTargets \\(ipl\\\\Orm\\\\Query\\) in isset\\(\\) is not nullable\\.$#" - count: 1 - path: application/controllers/ServicesController.php - - message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Controllers\\\\TacticalController\\:\\:completeAction\\(\\) has no return type specified\\.$#" count: 1 @@ -1260,11 +1210,6 @@ parameters: count: 1 path: application/forms/Command/CommandForm.php - - - message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Forms\\\\Command\\\\CommandForm\\:\\:filterGrantedOn\\(\\) has parameter \\$objects with no value type specified in iterable type Traversable\\.$#" - count: 1 - path: application/forms/Command/CommandForm.php - - message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Forms\\\\Command\\\\CommandForm\\:\\:onSuccess\\(\\) has no return type specified\\.$#" count: 1 @@ -1285,11 +1230,6 @@ parameters: count: 2 path: application/forms/Command/CommandForm.php - - - message: "#^Parameter \\#1 \\$objects of method Icinga\\\\Module\\\\Icingadb\\\\Forms\\\\Command\\\\CommandForm\\:\\:getCommands\\(\\) expects Traversable\\, mixed given\\.$#" - count: 1 - path: application/forms/Command/CommandForm.php - - message: "#^Parameter \\#1 \\$queryString of method Icinga\\\\Module\\\\Icingadb\\\\Forms\\\\Command\\\\CommandForm\\:\\:parseRestriction\\(\\) expects string, array\\ given\\.$#" count: 3 @@ -1350,11 +1290,6 @@ parameters: count: 1 path: application/forms/Command/Object/AcknowledgeProblemForm.php - - - message: "#^Parameter \\#1 \\$iterable of function ipl\\\\Stdlib\\\\iterable_value_first expects iterable, mixed given\\.$#" - count: 1 - path: application/forms/Command/Object/AcknowledgeProblemForm.php - - message: "#^Call to an undefined method ipl\\\\Html\\\\Contract\\\\FormElement\\:\\:isChecked\\(\\)\\.$#" count: 1 @@ -1375,46 +1310,16 @@ parameters: count: 1 path: application/forms/Command/Object/AddCommentForm.php - - - message: "#^Parameter \\#1 \\$iterable of function ipl\\\\Stdlib\\\\iterable_value_first expects iterable, mixed given\\.$#" - count: 1 - path: application/forms/Command/Object/AddCommentForm.php - - message: "#^Cannot call method getUsername\\(\\) on Icinga\\\\User\\|null\\.$#" count: 1 path: application/forms/Command/Object/DeleteCommentForm.php - - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: application/forms/Command/Object/DeleteDowntimeForm.php - - - - message: "#^Cannot access property \\$scheduled_by on mixed\\.$#" - count: 1 - path: application/forms/Command/Object/DeleteDowntimeForm.php - - message: "#^Cannot call method getUsername\\(\\) on Icinga\\\\User\\|null\\.$#" count: 1 path: application/forms/Command/Object/DeleteDowntimeForm.php - - - message: "#^Cannot access property \\$passive_checks_enabled on mixed\\.$#" - count: 1 - path: application/forms/Command/Object/ProcessCheckResultForm.php - - - - message: "#^Parameter \\#1 \\$iterable of function ipl\\\\Stdlib\\\\iterable_value_first expects iterable, mixed given\\.$#" - count: 2 - path: application/forms/Command/Object/ProcessCheckResultForm.php - - - - message: "#^Parameter \\#1 \\$objects of method Icinga\\\\Module\\\\Icingadb\\\\Command\\\\Object\\\\ObjectsCommand\\:\\:setObjects\\(\\) expects Traversable\\, Generator\\ given\\.$#" - count: 1 - path: application/forms/Command/Object/ProcessCheckResultForm.php - - message: "#^Parameter \\#1 \\$output of method Icinga\\\\Module\\\\Icingadb\\\\Command\\\\Object\\\\ProcessCheckResultCommand\\:\\:setOutput\\(\\) expects string, mixed given\\.$#" count: 1 @@ -1435,11 +1340,6 @@ parameters: count: 1 path: application/forms/Command/Object/RemoveAcknowledgementForm.php - - - message: "#^Parameter \\#1 \\$iterable of function ipl\\\\Stdlib\\\\iterable_value_first expects iterable, mixed given\\.$#" - count: 1 - path: application/forms/Command/Object/RemoveAcknowledgementForm.php - - message: "#^Call to an undefined method ipl\\\\Html\\\\Contract\\\\FormElement\\:\\:isChecked\\(\\)\\.$#" count: 1 @@ -1450,11 +1350,6 @@ parameters: count: 1 path: application/forms/Command/Object/ScheduleCheckForm.php - - - message: "#^Parameter \\#1 \\$iterable of function ipl\\\\Stdlib\\\\iterable_value_first expects iterable, mixed given\\.$#" - count: 1 - path: application/forms/Command/Object/ScheduleCheckForm.php - - message: "#^Call to an undefined method ipl\\\\Html\\\\Contract\\\\FormElement\\:\\:isChecked\\(\\)\\.$#" count: 2 @@ -1535,11 +1430,6 @@ parameters: count: 1 path: application/forms/Command/Object/SendCustomNotificationForm.php - - - message: "#^Parameter \\#1 \\$iterable of function ipl\\\\Stdlib\\\\iterable_value_first expects iterable, mixed given\\.$#" - count: 1 - path: application/forms/Command/Object/SendCustomNotificationForm.php - - message: "#^Cannot call method getAttributes\\(\\) on ipl\\\\Html\\\\Contract\\\\Wrappable\\|null\\.$#" count: 1