From 53bc583f7989004b23c40cb7fbd4fd7b41483b37 Mon Sep 17 00:00:00 2001 From: raviks789 <33730024+raviks789@users.noreply.github.com> Date: Tue, 27 Jun 2023 11:23:58 +0200 Subject: [PATCH] Fix PHP 8.2 support issues --- .github/workflows/php.yml | 1 + application/clicommands/Icinga2Command.php | 2 ++ application/forms/TimeRangePicker/CustomForm.php | 3 +++ library/Graphite/Graphing/Template.php | 1 + library/Graphite/Web/Controller/MonitoringAwareController.php | 3 +++ library/Graphite/Web/Widget/Graphs.php | 2 +- 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index a9b8371..78b01d5 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -33,6 +33,7 @@ jobs: - name: Setup dependencies run: composer require -n --no-progress overtrue/phplint && git clone --single-branch --branch master https://github.com/Icinga/icingaweb2.git vendor/icingaweb2 + && git clone --single-branch --branch master https://github.com/Icinga/icingadb-web.git vendor/icingadb-web && git clone --single-branch --branch snapshot/nightly https://github.com/Icinga/icinga-php-library.git vendor/icinga-php-library && git clone --single-branch --branch snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty diff --git a/application/clicommands/Icinga2Command.php b/application/clicommands/Icinga2Command.php index 816e063..e0e0ee4 100644 --- a/application/clicommands/Icinga2Command.php +++ b/application/clicommands/Icinga2Command.php @@ -138,6 +138,8 @@ EOT } } + assert(isset($service), '$service not initialized in the loop'); + $monObj = $service ? [ "apply Service \"{$icinga2CfgObjPrefix}_{$checkCommand}\" {", diff --git a/application/forms/TimeRangePicker/CustomForm.php b/application/forms/TimeRangePicker/CustomForm.php index 89b5833..8627267 100644 --- a/application/forms/TimeRangePicker/CustomForm.php +++ b/application/forms/TimeRangePicker/CustomForm.php @@ -126,6 +126,9 @@ class CustomForm extends Form ]); } + assert(isset($elementDecorators), '$elementDecorators not initialized in the loop'); + assert(isset($element), '$element not initialized in the loop'); + $decorators = []; foreach ($elementDecorators as $key => $decorator) { if ($key === 'Zend_Form_Decorator_ViewHelper') { diff --git a/library/Graphite/Graphing/Template.php b/library/Graphite/Graphing/Template.php index a030fb7..0950fed 100644 --- a/library/Graphite/Graphing/Template.php +++ b/library/Graphite/Graphing/Template.php @@ -203,6 +203,7 @@ class Template } } unset($_); + assert(isset($nextCurveName), 'loop did not initialize variable $nextCurveName'); $allowedNextCurveMetricsPerCurrentCurveName = []; foreach ($currentCombination as $currentCurveName => $currentCurveMetric) { diff --git a/library/Graphite/Web/Controller/MonitoringAwareController.php b/library/Graphite/Web/Controller/MonitoringAwareController.php index dca2ebd..d4f1a07 100644 --- a/library/Graphite/Web/Controller/MonitoringAwareController.php +++ b/library/Graphite/Web/Controller/MonitoringAwareController.php @@ -22,6 +22,9 @@ abstract class MonitoringAwareController extends Controller /** @var bool Whether to use icingadb as the backend */ protected $useIcingadbAsBackend = false; + /** @var MonitoringBackend */ + protected $backend; + /** * Restrict the given monitored object query for the currently authenticated user * diff --git a/library/Graphite/Web/Widget/Graphs.php b/library/Graphite/Web/Widget/Graphs.php index e18b8da..29c3160 100644 --- a/library/Graphite/Web/Widget/Graphs.php +++ b/library/Graphite/Web/Widget/Graphs.php @@ -134,7 +134,7 @@ abstract class Graphs extends AbstractWidget * * @param MonitoredObject $object * - * @return static + * @return ?static */ public static function forMonitoredObject(MonitoredObject $object) {