From d2f1a4dbde9663e57da31a84e80f457efa931837 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 21 Aug 2023 14:33:45 +0200 Subject: [PATCH] Add variable type hint to `Icinga::app()`'s returned object --- library/Icingadb/Data/PivotTable.php | 6 ++++-- library/Icingadb/Web/Controller.php | 5 ++++- library/Icingadb/Widget/Detail/ObjectDetail.php | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/library/Icingadb/Data/PivotTable.php b/library/Icingadb/Data/PivotTable.php index 9733381c..1aee20cc 100644 --- a/library/Icingadb/Data/PivotTable.php +++ b/library/Icingadb/Data/PivotTable.php @@ -5,6 +5,7 @@ namespace Icinga\Module\Icingadb\Data; use Icinga\Application\Icinga; +use Icinga\Application\Web; use ipl\Orm\Query; use ipl\Stdlib\Contract\Paginatable; use ipl\Stdlib\Filter; @@ -209,9 +210,10 @@ class PivotTable */ protected function getPaginationParameter(string $axis, string $param, int $default = null): int { - $request = Icinga::app()->getRequest(); + /** @var Web $app */ + $app = Icinga::app(); - $value = $request->getParam($param, ''); + $value = $app->getRequest()->getParam($param, ''); if (strpos($value, ',') > 0) { $parts = explode(',', $value, 2); return intval($parts[$axis === 'x' ? 0 : 1]); diff --git a/library/Icingadb/Web/Controller.php b/library/Icingadb/Web/Controller.php index 49bd1c79..5003df27 100644 --- a/library/Icingadb/Web/Controller.php +++ b/library/Icingadb/Web/Controller.php @@ -11,6 +11,7 @@ use Icinga\Application\Config; use Icinga\Application\Icinga; use Icinga\Application\Logger; use Icinga\Application\Version; +use Icinga\Application\Web; use Icinga\Data\ConfigObject; use Icinga\Date\DateFormatter; use Icinga\Exception\ConfigurationError; @@ -535,7 +536,9 @@ class Controller extends CompatController protected function moduleInit() { - Icinga::app()->getFrontController() + /** @var Web $app */ + $app = Icinga::app(); + $app->getFrontController() ->getPlugin('Zend_Controller_Plugin_ErrorHandler') ->setErrorHandlerModule('icingadb'); } diff --git a/library/Icingadb/Widget/Detail/ObjectDetail.php b/library/Icingadb/Widget/Detail/ObjectDetail.php index edb9bf09..035e329c 100644 --- a/library/Icingadb/Widget/Detail/ObjectDetail.php +++ b/library/Icingadb/Widget/Detail/ObjectDetail.php @@ -10,6 +10,7 @@ use Icinga\Application\Hook; use Icinga\Application\Hook\GrapherHook; use Icinga\Application\Icinga; use Icinga\Application\Logger; +use Icinga\Application\Web; use Icinga\Date\DateFormatter; use Icinga\Exception\IcingaException; use Icinga\Module\Icingadb\Common\Auth; @@ -483,8 +484,10 @@ class ObjectDetail extends BaseHtmlElement } try { + /** @var Web $app */ + $app = Icinga::app(); $renderedExtension = $extension - ->setView(Icinga::app()->getViewRenderer()->view) + ->setView($app->getViewRenderer()->view) ->getHtmlForObject($this->compatObject()); $extensionHtml = new HtmlElement(