From 8622514fcdc48b9c85af7dbc6e87b2b718b05b06 Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Mon, 1 Dec 2025 13:56:21 +0100 Subject: [PATCH 1/5] Change implicit nullable type declaration to explicit Since PHP 8.4 implicitly nullable parameter types are deprecated. Normalize scoped PHPDoc for nullable-parameter updates: use `?Type` instead of `Type|null` and remove column alignment. Co-authored-by: "Eric Lippmann " --- application/clicommands/MigrateCommand.php | 2 +- application/forms/RedisConfigForm.php | 10 ++--- .../Object/ProcessCheckResultCommand.php | 6 +-- .../Command/Transport/ApiCommandTransport.php | 4 +- .../Command/Transport/CommandTransport.php | 10 ++--- .../Transport/CommandTransportInterface.php | 8 ++-- library/Icingadb/Common/HostStates.php | 8 ++-- library/Icingadb/Common/IcingaRedis.php | 16 ++++---- library/Icingadb/Common/ServiceStates.php | 8 ++-- library/Icingadb/Common/StateBadges.php | 2 +- library/Icingadb/Compat/UrlMigrator.php | 6 +-- library/Icingadb/Data/PivotTable.php | 38 +++++++++---------- .../Hook/Common/TotalSlaReportUtils.php | 2 +- library/Icingadb/Model/UnreachableParent.php | 2 +- .../ProvidedHook/Reporting/HostSlaReport.php | 2 +- .../Reporting/ServiceSlaReport.php | 2 +- .../ProvidedHook/Reporting/SlaReport.php | 10 ++--- library/Icingadb/ProvidedHook/X509/Sni.php | 2 +- library/Icingadb/Util/PerfDataSet.php | 4 +- library/Icingadb/Web/Controller.php | 6 +-- .../Web/Navigation/Renderer/ProblemsBadge.php | 2 +- .../Icingadb/Widget/Detail/CustomVarTable.php | 2 +- library/Icingadb/Widget/ShowMore.php | 2 +- .../Icingadb/Common/StateBadgesTest.php | 2 +- 24 files changed, 78 insertions(+), 78 deletions(-) diff --git a/application/clicommands/MigrateCommand.php b/application/clicommands/MigrateCommand.php index c5eb8fbf4..b5accb8c5 100644 --- a/application/clicommands/MigrateCommand.php +++ b/application/clicommands/MigrateCommand.php @@ -787,7 +787,7 @@ private function readFromIni($path, &$rc) return $config; } - private function createBackupIni(string $path, Config $config = null): void + private function createBackupIni(string $path, ?Config $config = null): void { $counter = 0; while (true) { diff --git a/application/forms/RedisConfigForm.php b/application/forms/RedisConfigForm.php index cfaa07503..ef911c1dd 100644 --- a/application/forms/RedisConfigForm.php +++ b/application/forms/RedisConfigForm.php @@ -676,13 +676,13 @@ public static function checkRedis(Form $form): bool * Wraps the given IPL validator class into a callback validator * for usage as the only validator of the element given by name. * - * @param string $cls IPL validator class FQN - * @param string $element Form element name - * @param Closure $additionalValidator + * @param string $cls IPL validator class FQN + * @param string $element Form element name + * @param ?Closure $additionalValidator * - * @return array Callback validator + * @return array Callback validator */ - private function wrapIplValidator(string $cls, string $element, Closure $additionalValidator = null): array + private function wrapIplValidator(string $cls, string $element, ?Closure $additionalValidator = null): array { return [ 'Callback', diff --git a/library/Icingadb/Command/Object/ProcessCheckResultCommand.php b/library/Icingadb/Command/Object/ProcessCheckResultCommand.php index 875a5f186..d63912c1a 100644 --- a/library/Icingadb/Command/Object/ProcessCheckResultCommand.php +++ b/library/Icingadb/Command/Object/ProcessCheckResultCommand.php @@ -118,11 +118,11 @@ public function getOutput() /** * Set the performance data of the host or service check result * - * @param string|null $performanceData + * @param ?string $performanceData * - * @return $this + * @return $this */ - public function setPerformanceData(string $performanceData = null): self + public function setPerformanceData(?string $performanceData = null): self { $this->performanceData = $performanceData; diff --git a/library/Icingadb/Command/Transport/ApiCommandTransport.php b/library/Icingadb/Command/Transport/ApiCommandTransport.php index 3857d8657..1d8f497a0 100644 --- a/library/Icingadb/Command/Transport/ApiCommandTransport.php +++ b/library/Icingadb/Command/Transport/ApiCommandTransport.php @@ -301,13 +301,13 @@ protected function sendCommand(IcingaApiCommand $command) * Send the Icinga command over the Icinga 2 API * * @param IcingaCommand|IcingaApiCommand $command - * @param int|null $now + * @param ?int $now * * @throws CommandTransportException * * @return mixed */ - public function send(IcingaCommand|IcingaApiCommand $command, int $now = null) + public function send(IcingaCommand|IcingaApiCommand $command, ?int $now = null) { if ($command instanceof IcingaCommand) { $command = $this->renderer->render($command); diff --git a/library/Icingadb/Command/Transport/CommandTransport.php b/library/Icingadb/Command/Transport/CommandTransport.php index 75cad0320..03358a1e9 100644 --- a/library/Icingadb/Command/Transport/CommandTransport.php +++ b/library/Icingadb/Command/Transport/CommandTransport.php @@ -94,14 +94,14 @@ public static function createTransport(ConfigObject $config): ApiCommandTranspor * * This will try one configured transport after another until the command has been successfully sent. * - * @param IcingaCommand $command The command to send - * @param int|null $now Timestamp of the command or null for now + * @param IcingaCommand $command The command to send + * @param ?int $now Timestamp of the command or null for now * - * @throws CommandTransportException If sending the Icinga command failed + * @return mixed * - * @return mixed + * @throws CommandTransportException If sending the Icinga command failed */ - public function send(IcingaCommand $command, int $now = null) + public function send(IcingaCommand $command, ?int $now = null) { $errors = []; $results = []; diff --git a/library/Icingadb/Command/Transport/CommandTransportInterface.php b/library/Icingadb/Command/Transport/CommandTransportInterface.php index 484234616..ac5dc6423 100644 --- a/library/Icingadb/Command/Transport/CommandTransportInterface.php +++ b/library/Icingadb/Command/Transport/CommandTransportInterface.php @@ -15,10 +15,10 @@ interface CommandTransportInterface /** * Send an Icinga command over the Icinga command transport * - * @param IcingaCommand $command The command to send - * @param int|null $now Timestamp of the command or null for now + * @param IcingaCommand $command The command to send + * @param ?int $now Timestamp of the command or null for now * - * @throws CommandTransportException If sending the Icinga command failed + * @throws CommandTransportException If sending the Icinga command failed */ - public function send(IcingaCommand $command, int $now = null); + public function send(IcingaCommand $command, ?int $now = null); } diff --git a/library/Icingadb/Common/HostStates.php b/library/Icingadb/Common/HostStates.php index 06b6dad5f..cf2840c58 100644 --- a/library/Icingadb/Common/HostStates.php +++ b/library/Icingadb/Common/HostStates.php @@ -47,13 +47,13 @@ public static function int(string $state): int /** * Get the textual representation of the passed host state * - * @param int|null $state + * @param ?int $state * * @return string * * @throws \InvalidArgumentException If the given host state is invalid, i.e. not known */ - public static function text(int $state = null): string + public static function text(?int $state = null): string { switch (true) { case $state === self::UP: @@ -78,13 +78,13 @@ public static function text(int $state = null): string /** * Get the translated textual representation of the passed host state * - * @param int|null $state + * @param ?int $state * * @return string * * @throws \InvalidArgumentException If the given host state is invalid, i.e. not known */ - public static function translated(int $state = null): string + public static function translated(?int $state = null): string { switch (true) { case $state === self::UP: diff --git a/library/Icingadb/Common/IcingaRedis.php b/library/Icingadb/Common/IcingaRedis.php index 231ecc011..3e9a1293b 100644 --- a/library/Icingadb/Common/IcingaRedis.php +++ b/library/Icingadb/Common/IcingaRedis.php @@ -173,11 +173,11 @@ protected function fetchState(string $key, array $ids, array $columns): Generato /** * Get the last icinga heartbeat from redis * - * @param Redis|null $redis + * @param ?Redis $redis * * @return float|int|null */ - public static function getLastIcingaHeartbeat(Redis $redis = null) + public static function getLastIcingaHeartbeat(?Redis $redis = null) { if ($redis === null) { $redis = Backend::getRedis()->getConnection(); @@ -201,12 +201,12 @@ public static function getLastIcingaHeartbeat(Redis $redis = null) /** * Get the primary redis instance * - * @param Config|null $moduleConfig - * @param Config|null $redisConfig + * @param ?Config $moduleConfig + * @param ?Config $redisConfig * * @return Redis */ - public static function getPrimaryRedis(Config $moduleConfig = null, Config $redisConfig = null): Redis + public static function getPrimaryRedis(?Config $moduleConfig = null, ?Config $redisConfig = null): Redis { if ($moduleConfig === null) { $moduleConfig = Config::module('icingadb'); @@ -235,12 +235,12 @@ public static function getPrimaryRedis(Config $moduleConfig = null, Config $redi /** * Get the secondary redis instance if exists * - * @param Config|null $moduleConfig - * @param Config|null $redisConfig + * @param ?Config $moduleConfig + * @param ?Config $redisConfig * * @return ?Redis */ - public static function getSecondaryRedis(Config $moduleConfig = null, Config $redisConfig = null) + public static function getSecondaryRedis(?Config $moduleConfig = null, ?Config $redisConfig = null) { if ($moduleConfig === null) { $moduleConfig = Config::module('icingadb'); diff --git a/library/Icingadb/Common/ServiceStates.php b/library/Icingadb/Common/ServiceStates.php index 68aea14c8..5dd6b1148 100644 --- a/library/Icingadb/Common/ServiceStates.php +++ b/library/Icingadb/Common/ServiceStates.php @@ -57,13 +57,13 @@ public static function int(string $state): int /** * Get the textual representation of the passed service state * - * @param int|null $state + * @param ?int $state * * @return string * * @throws \InvalidArgumentException If the given service state is invalid, i.e. not known */ - public static function text(int $state = null): string + public static function text(?int $state = null): string { switch (true) { case $state === self::OK: @@ -94,13 +94,13 @@ public static function text(int $state = null): string /** * Get the translated textual representation of the passed service state * - * @param int|null $state + * @param ?int $state * * @return string * * @throws \InvalidArgumentException If the given service state is invalid, i.e. not known */ - public static function translated(int $state = null): string + public static function translated(?int $state = null): string { switch (true) { case $state === self::OK: diff --git a/library/Icingadb/Common/StateBadges.php b/library/Icingadb/Common/StateBadges.php index eaa246e53..f30226f6e 100644 --- a/library/Icingadb/Common/StateBadges.php +++ b/library/Icingadb/Common/StateBadges.php @@ -118,7 +118,7 @@ public function setUrl(Url $url): self * * @return Link */ - protected function createLink($content, Filter\Rule $filter = null): Link + protected function createLink($content, ?Filter\Rule $filter = null): Link { $url = clone $this->getUrl(); diff --git a/library/Icingadb/Compat/UrlMigrator.php b/library/Icingadb/Compat/UrlMigrator.php index 8d5321c28..62e9ac5c1 100644 --- a/library/Icingadb/Compat/UrlMigrator.php +++ b/library/Icingadb/Compat/UrlMigrator.php @@ -84,7 +84,7 @@ public static function transformUrl(Url $url): Url return $url; } - public static function transformParams(Url $url, string $transformerName = null): array + public static function transformParams(Url $url, ?string $transformerName = null): array { $transformer = new self(); @@ -153,11 +153,11 @@ public static function transformParams(Url $url, string $transformerName = null) * Transform the given legacy filter * * @param Filter\Rule $filter - * @param string|null $queryTransformer + * @param ?string $queryTransformer * * @return Filter\Rule|false */ - public static function transformFilter(Filter\Rule $filter, string $queryTransformer = null) + public static function transformFilter(Filter\Rule $filter, ?string $queryTransformer = null) { $transformer = new self(); diff --git a/library/Icingadb/Data/PivotTable.php b/library/Icingadb/Data/PivotTable.php index 2e75a5c82..4613c355f 100644 --- a/library/Icingadb/Data/PivotTable.php +++ b/library/Icingadb/Data/PivotTable.php @@ -115,11 +115,11 @@ public function __construct(Query $query, string $xAxisColumn, string $yAxisColu /** * Set the filter to apply on the query for the x-axis * - * @param Filter\Rule $filter + * @param ?Filter\Rule $filter * - * @return $this + * @return $this */ - public function setXAxisFilter(Filter\Rule $filter = null): self + public function setXAxisFilter(?Filter\Rule $filter = null): self { $this->xAxisFilter = $filter; return $this; @@ -128,11 +128,11 @@ public function setXAxisFilter(Filter\Rule $filter = null): self /** * Set the filter to apply on the query for the y-axis * - * @param Filter\Rule $filter + * @param ?Filter\Rule $filter * - * @return $this + * @return $this */ - public function setYAxisFilter(Filter\Rule $filter = null): self + public function setYAxisFilter(?Filter\Rule $filter = null): self { $this->yAxisFilter = $filter; return $this; @@ -203,13 +203,13 @@ public function setYAxisHeader(string $yAxisHeader): self /** * Return the value for the given request parameter * - * @param string $axis The axis for which to return the parameter ('x' or 'y') - * @param string $param The parameter name to return - * @param int $default The default value to return + * @param string $axis The axis for which to return the parameter ('x' or 'y') + * @param string $param The parameter name to return + * @param ?int $default The default value to return * - * @return int + * @return int */ - protected function getPaginationParameter(string $axis, string $param, int $default = null): int + protected function getPaginationParameter(string $axis, string $param, ?int $default = null): int { /** @var Web $app */ $app = Icinga::app(); @@ -326,12 +326,12 @@ protected function queryYAxis(): Query * * $limit and $page are taken from the current request if not given. * - * @param int $limit The maximum amount of entries to fetch - * @param int $page The page to set as current one + * @param ?int $limit The maximum amount of entries to fetch + * @param ?int $page The page to set as current one * - * @return Paginatable + * @return Paginatable */ - public function paginateXAxis(int $limit = null, int $page = null): Paginatable + public function paginateXAxis(?int $limit = null, ?int $page = null): Paginatable { if ($limit === null || $page === null) { if ($limit === null) { @@ -358,12 +358,12 @@ public function paginateXAxis(int $limit = null, int $page = null): Paginatable * * $limit and $page are taken from the current request if not given. * - * @param int $limit The maximum amount of entries to fetch - * @param int $page The page to set as current one + * @param ?int $limit The maximum amount of entries to fetch + * @param ?int $page The page to set as current one * - * @return Paginatable + * @return Paginatable */ - public function paginateYAxis(int $limit = null, int $page = null): Paginatable + public function paginateYAxis(?int $limit = null, ?int $page = null): Paginatable { if ($limit === null || $page === null) { if ($limit === null) { diff --git a/library/Icingadb/Hook/Common/TotalSlaReportUtils.php b/library/Icingadb/Hook/Common/TotalSlaReportUtils.php index 687c0c0fb..5ae5dcb1d 100644 --- a/library/Icingadb/Hook/Common/TotalSlaReportUtils.php +++ b/library/Icingadb/Hook/Common/TotalSlaReportUtils.php @@ -14,7 +14,7 @@ trait TotalSlaReportUtils { - public function getHtml(Timerange $timerange, array $config = null) + public function getHtml(Timerange $timerange, ?array $config = null) { $data = $this->getData($timerange, $config); $count = $data->count(); diff --git a/library/Icingadb/Model/UnreachableParent.php b/library/Icingadb/Model/UnreachableParent.php index acb9dc37a..0d634f49f 100644 --- a/library/Icingadb/Model/UnreachableParent.php +++ b/library/Icingadb/Model/UnreachableParent.php @@ -86,7 +86,7 @@ public function createBehaviors(Behaviors $behaviors): void ])); } - public static function on(Connection $db, Model $root = null): Query + public static function on(Connection $db, ?Model $root = null): Query { if ($root === null) { throw new InvalidArgumentException('Root node must not be null'); diff --git a/library/Icingadb/ProvidedHook/Reporting/HostSlaReport.php b/library/Icingadb/ProvidedHook/Reporting/HostSlaReport.php index d12d646af..e975545c6 100644 --- a/library/Icingadb/ProvidedHook/Reporting/HostSlaReport.php +++ b/library/Icingadb/ProvidedHook/Reporting/HostSlaReport.php @@ -45,7 +45,7 @@ protected function createReportRow($row) ->setValues([(float) $row->sla]); } - protected function fetchSla(Timerange $timerange, Rule $filter = null) + protected function fetchSla(Timerange $timerange, ?Rule $filter = null) { $sla = Host::on($this->getDb()) ->columns([ diff --git a/library/Icingadb/ProvidedHook/Reporting/ServiceSlaReport.php b/library/Icingadb/ProvidedHook/Reporting/ServiceSlaReport.php index 4b1180504..fb281d5cf 100644 --- a/library/Icingadb/ProvidedHook/Reporting/ServiceSlaReport.php +++ b/library/Icingadb/ProvidedHook/Reporting/ServiceSlaReport.php @@ -45,7 +45,7 @@ protected function createReportRow($row) ->setValues([(float) $row->sla]); } - protected function fetchSla(Timerange $timerange, Rule $filter = null) + protected function fetchSla(Timerange $timerange, ?Rule $filter = null) { $sla = Service::on($this->getDb()) ->columns([ diff --git a/library/Icingadb/ProvidedHook/Reporting/SlaReport.php b/library/Icingadb/ProvidedHook/Reporting/SlaReport.php index 0d4cae368..6e3bb81da 100644 --- a/library/Icingadb/ProvidedHook/Reporting/SlaReport.php +++ b/library/Icingadb/ProvidedHook/Reporting/SlaReport.php @@ -56,13 +56,13 @@ abstract protected function createReportRow($row); * Fetch SLA according to specified time range and filter * * @param Timerange $timerange - * @param Rule|null $filter + * @param ?Rule $filter * * @return iterable */ - abstract protected function fetchSla(Timerange $timerange, Rule $filter = null); + abstract protected function fetchSla(Timerange $timerange, ?Rule $filter = null); - protected function fetchReportData(Timerange $timerange, array $config = null) + protected function fetchReportData(Timerange $timerange, ?array $config = null) { $rd = $this->createReportData(); $rows = []; @@ -214,12 +214,12 @@ public function initConfigForm(Form $form) ]); } - public function getData(Timerange $timerange, array $config = null) + public function getData(Timerange $timerange, ?array $config = null) { return $this->fetchReportData($timerange, $config); } - public function getHtml(Timerange $timerange, array $config = null) + public function getHtml(Timerange $timerange, ?array $config = null) { $data = $this->getData($timerange, $config); diff --git a/library/Icingadb/ProvidedHook/X509/Sni.php b/library/Icingadb/ProvidedHook/X509/Sni.php index eab1946c8..5de953cc2 100644 --- a/library/Icingadb/ProvidedHook/X509/Sni.php +++ b/library/Icingadb/ProvidedHook/X509/Sni.php @@ -21,7 +21,7 @@ class Sni extends SniHook /** * @inheritDoc */ - public function getHosts(Filter $filter = null): Generator + public function getHosts(?Filter $filter = null): Generator { $this->getDb()->ping(); diff --git a/library/Icingadb/Util/PerfDataSet.php b/library/Icingadb/Util/PerfDataSet.php index 19c4b9af8..f4303ecc6 100644 --- a/library/Icingadb/Util/PerfDataSet.php +++ b/library/Icingadb/Util/PerfDataSet.php @@ -135,11 +135,11 @@ protected function readLabel(): string * Return all characters between the current parser position and the given character * * @param string $stopChar The character on which to stop - * @param string $backtrackOn The character on which to backtrack + * @param ?string $backtrackOn The character on which to backtrack * * @return string */ - protected function readUntil(string $stopChar, string $backtrackOn = null): string + protected function readUntil(string $stopChar, ?string $backtrackOn = null): string { $start = $this->parserPos; $breakCharEncounteredAt = null; diff --git a/library/Icingadb/Web/Controller.php b/library/Icingadb/Web/Controller.php index 45429e2d4..ea045aa76 100644 --- a/library/Icingadb/Web/Controller.php +++ b/library/Icingadb/Web/Controller.php @@ -319,11 +319,11 @@ protected function prepareSearchFilter(Query $query, string $search, Filter\Any /** * Require permission to access the given route * - * @param string $name If NULL, the current controller name is used + * @param ?string $name If NULL, the current controller name is used * * @throws SecurityException */ - public function assertRouteAccess(string $name = null) + public function assertRouteAccess(?string $name = null) { if (! $name) { $name = $this->getRequest()->getControllerName(); @@ -451,7 +451,7 @@ protected function addContent(ValidHtml $content) return parent::addContent($content); } - public function filter(Query $query, Filter\Rule $filter = null): self + public function filter(Query $query, ?Filter\Rule $filter = null): self { if ($this->format !== 'sql' || $this->hasPermission('config/authentication/roles/show')) { $this->applyRestrictions($query); diff --git a/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php b/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php index 85a8b01cf..db1fc13e1 100644 --- a/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php +++ b/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php @@ -115,7 +115,7 @@ public function getTitle() return $this->title; } - public function render(NavigationItem $item = null): string + public function render(?NavigationItem $item = null): string { if ($item === null) { $item = $this->getItem(); diff --git a/library/Icingadb/Widget/Detail/CustomVarTable.php b/library/Icingadb/Widget/Detail/CustomVarTable.php index e2265e0e2..67359e093 100644 --- a/library/Icingadb/Widget/Detail/CustomVarTable.php +++ b/library/Icingadb/Widget/Detail/CustomVarTable.php @@ -52,7 +52,7 @@ class CustomVarTable extends BaseHtmlElement * @param iterable $data * @param ?Model $object */ - public function __construct($data, Model $object = null) + public function __construct($data, ?Model $object = null) { $this->data = $data; $this->object = $object; diff --git a/library/Icingadb/Widget/ShowMore.php b/library/Icingadb/Widget/ShowMore.php index 4558c50df..faaf6f507 100644 --- a/library/Icingadb/Widget/ShowMore.php +++ b/library/Icingadb/Widget/ShowMore.php @@ -28,7 +28,7 @@ class ShowMore extends BaseHtmlElement /** @var ?string */ protected $label; - public function __construct(ResultSet $resultSet, Url $url, string $label = null) + public function __construct(ResultSet $resultSet, Url $url, ?string $label = null) { $this->label = $label; $this->resultSet = $resultSet; diff --git a/test/php/library/Icingadb/Common/StateBadgesTest.php b/test/php/library/Icingadb/Common/StateBadgesTest.php index 45c329115..4aad786cf 100644 --- a/test/php/library/Icingadb/Common/StateBadgesTest.php +++ b/test/php/library/Icingadb/Common/StateBadgesTest.php @@ -84,7 +84,7 @@ protected function getStateInt(string $state): int return 0; } - public function generateLink($content, Filter\Rule $filter = null): Link + public function generateLink($content, ?Filter\Rule $filter = null): Link { return parent::createLink($content, $filter); } From 6496317723226b37a35a70ea3e813d6aefe44dd7 Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Mon, 1 Dec 2025 14:15:11 +0100 Subject: [PATCH 2/5] Remove no-op `ReflectionProperty::setAccessible()` calls `ReflectionProperty::setAccessible()` has had no effect since PHP 8.1, as all properties are accessible via reflection by default. The method is deprecated as of PHP 8.5. --- library/Icingadb/Model/UnreachableParent.php | 1 - 1 file changed, 1 deletion(-) diff --git a/library/Icingadb/Model/UnreachableParent.php b/library/Icingadb/Model/UnreachableParent.php index 0d634f49f..15832419d 100644 --- a/library/Icingadb/Model/UnreachableParent.php +++ b/library/Icingadb/Model/UnreachableParent.php @@ -188,7 +188,6 @@ private static function selectNodes(Connection $db, Model $root): Select // TODO: ipl-orm doesn't preserve key order :'( $columnsProperty = (new \ReflectionClass($nodeSelect))->getProperty('columns'); - $columnsProperty->setAccessible(true); $columnsProperty->setValue($nodeSelect, array_merge( [ 'id' => null, From ca4f9a39cee17da91494c6c92b8bc2b9faffc2a1 Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Mon, 1 Dec 2025 14:20:10 +0100 Subject: [PATCH 3/5] Use `PDO` MySQL driver-specific constants Replace deprecated `PDO::MYSQL_*` constant usage with the driver-specific `Pdo\Mysql::ATTR_*` constants introduced in PHP 8.4. This prepares the code for PHP 8.5, where accessing MySQL driver constants through the generic `PDO` class is deprecated. This change requires a compatibility shim on older PHP versions to provide `Pdo\Mysql` for runtimes that do not expose the driver-specific class yet. The shim is provided in `ipl-sql`. --- library/Icingadb/Common/Backend.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Icingadb/Common/Backend.php b/library/Icingadb/Common/Backend.php index 15cb93ccf..26d52f0cb 100644 --- a/library/Icingadb/Common/Backend.php +++ b/library/Icingadb/Common/Backend.php @@ -15,6 +15,7 @@ use ipl\Sql\QueryBuilder; use ipl\Sql\Select; use PDO; +use Pdo\Mysql; /** * Singleton providing access to the Icinga DB and Redis @@ -61,7 +62,8 @@ public static function getDb(): Connection $config->options = [PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ]; if ($config->db === 'mysql') { - $config->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET SESSION SQL_MODE='STRICT_TRANS_TABLES" + $config->options[Mysql::ATTR_INIT_COMMAND] + = "SET SESSION SQL_MODE='STRICT_TRANS_TABLES" . ",NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'"; } From 8af79a61b2c6f85c7162564663573d65c17f7ebf Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Mon, 1 Dec 2025 15:49:01 +0100 Subject: [PATCH 4/5] Avoid using `null` as an array key or as the key to `array_key_exists()` Passing `null` as the key to `array_key_exists()` or using it as an array key is deprecated as of PHP 8.5. Co-authored-by: Eric Lippmann --- library/Icingadb/Model/Behavior/Bitmask.php | 2 +- library/Icingadb/Web/Control/ViewModeSwitcher.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/library/Icingadb/Model/Behavior/Bitmask.php b/library/Icingadb/Model/Behavior/Bitmask.php index b09446180..b6026388c 100644 --- a/library/Icingadb/Model/Behavior/Bitmask.php +++ b/library/Icingadb/Model/Behavior/Bitmask.php @@ -57,7 +57,7 @@ public function toDb($value, $key, $context) public function rewriteCondition(Condition $condition, $relation = null) { $column = $condition->metaData()->get('columnName'); - if (! isset($this->properties[$column])) { + if ($column === null || ! isset($this->properties[$column])) { return; } diff --git a/library/Icingadb/Web/Control/ViewModeSwitcher.php b/library/Icingadb/Web/Control/ViewModeSwitcher.php index 0ca569d33..11433747d 100644 --- a/library/Icingadb/Web/Control/ViewModeSwitcher.php +++ b/library/Icingadb/Web/Control/ViewModeSwitcher.php @@ -105,7 +105,8 @@ public function getViewMode(): string { $viewMode = $this->getPopulatedValue($this->getViewModeParam(), $this->getDefaultViewMode()); - if (array_key_exists($viewMode, static::$viewModes)) { + // View mode stays null if explicitly populated with null. + if ($viewMode !== null && array_key_exists($viewMode, static::$viewModes)) { return $viewMode; } From 5053fb30b618e2f23b6030a0fcbd9dea12908339 Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Fri, 5 Dec 2025 14:36:38 +0100 Subject: [PATCH 5/5] Clean up and merge PHPStan baselines Remove errors no longer reported. Since PHP 7.x is no longer supported, remove the 7.x baseline. It is now no longer necessary to have multiple baseline files. --- phpstan-baseline-7x.neon | 106 ----- phpstan-baseline-8x.neon | 101 ----- phpstan-baseline-by-php-version.php | 15 - ...ine-standard.neon => phpstan-baseline.neon | 424 ++++-------------- phpstan.neon | 3 +- 5 files changed, 99 insertions(+), 550 deletions(-) delete mode 100644 phpstan-baseline-7x.neon delete mode 100644 phpstan-baseline-8x.neon delete mode 100644 phpstan-baseline-by-php-version.php rename phpstan-baseline-standard.neon => phpstan-baseline.neon (95%) diff --git a/phpstan-baseline-7x.neon b/phpstan-baseline-7x.neon deleted file mode 100644 index 95668ced4..000000000 --- a/phpstan-baseline-7x.neon +++ /dev/null @@ -1,106 +0,0 @@ -parameters: - ignoreErrors: - - - message: "#^Parameter \\#1 \\$data of function hex2bin expects string, mixed given\\.$#" - count: 1 - path: application/controllers/EventController.php - - - - message: "#^Parameter \\#1 \\$str of function md5 expects string, mixed given\\.$#" - count: 1 - path: application/forms/RedisConfigForm.php - - - - message: "#^Parameter \\#1 \\$stack of function array_pop expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Command/Transport/ApiCommandTransport.php - - - - message: "#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Common/IcingaRedis.php - - - - message: "#^Parameter \\#1 \\$arr1 of function array_diff_key expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Common/ObjectInspectionDetail.php - - - - message: "#^Parameter \\#1 \\$data of function bin2hex expects string, mixed given\\.$#" - count: 1 - path: library/Icingadb/Common/ObjectInspectionDetail.php - - - - message: "#^Parameter \\#1 \\$str of function strtolower expects string, mixed given\\.$#" - count: 2 - path: library/Icingadb/Compat/UrlMigrator.php - - - - message: "#^Parameter \\#1 \\$input of function array_keys expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Data/CsvResultSet.php - - - - message: "#^Parameter \\#1 \\$input of function array_values expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Data/CsvResultSet.php - - - - message: "#^Parameter \\#2 \\$str of function explode expects string, mixed given\\.$#" - count: 1 - path: library/Icingadb/Data/PivotTable.php - - - - message: "#^Parameter \\#1 \\$input of function array_keys expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Data/VolatileCsvResults.php - - - - message: "#^Parameter \\#1 \\$input of function array_values expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Data/VolatileCsvResults.php - - - - message: "#^Parameter \\#2 \\$str of function explode expects string, mixed given\\.$#" - count: 1 - path: library/Icingadb/Model/Behavior/ActionAndNoteUrl.php - - - - message: "#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, array\\\\|false given\\.$#" - count: 1 - path: library/Icingadb/Model/CustomvarFlat.php - - - - message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, Icinga\\\\Module\\\\Reporting\\\\ReportData\\|null given\\.$#" - count: 1 - path: library/Icingadb/ProvidedHook/Reporting/SlaReport.php - - - - message: "#^Parameter \\#1 \\$number of function number_format expects float, float\\|int\\|string given\\.$#" - count: 1 - path: library/Icingadb/Util/PerfData.php - - - - message: "#^Parameter \\#1 \\$str of function trim expects string, string\\|null given\\.$#" - count: 1 - path: library/Icingadb/Util/PluginOutput.php - - - - message: "#^Parameter \\#3 \\$encoding of function htmlspecialchars expects string, null given\\.$#" - count: 1 - path: library/Icingadb/Util/PluginOutput.php - - - - message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#" - count: 1 - path: library/Icingadb/Web/Controller.php - - - - 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 deleted file mode 100644 index d27ed7950..000000000 --- a/phpstan-baseline-8x.neon +++ /dev/null @@ -1,101 +0,0 @@ -parameters: - ignoreErrors: - - - message: "#^Parameter \\#1 \\$string of function hex2bin expects string, mixed given\\.$#" - count: 1 - path: application/controllers/EventController.php - - - - message: "#^Parameter \\#1 \\$string of function md5 expects string, mixed given\\.$#" - count: 1 - path: application/forms/RedisConfigForm.php - - - - message: "#^Parameter \\#1 \\$array of function array_pop expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Command/Transport/ApiCommandTransport.php - - - - message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Common/IcingaRedis.php - - - - message: "#^Parameter \\#1 \\$array of function array_diff_key expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Common/ObjectInspectionDetail.php - - - - message: "#^Parameter \\#1 \\$string of function bin2hex expects string, mixed given\\.$#" - count: 1 - path: library/Icingadb/Common/ObjectInspectionDetail.php - - - - message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#" - count: 2 - path: library/Icingadb/Compat/UrlMigrator.php - - - - message: "#^Parameter \\#1 \\$array of function array_keys expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Data/CsvResultSet.php - - - - message: "#^Parameter \\#1 \\$array of function array_values expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Data/CsvResultSet.php - - - - message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#" - count: 1 - path: library/Icingadb/Data/PivotTable.php - - - - message: "#^Parameter \\#1 \\$array of function array_keys expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Data/VolatileCsvResults.php - - - - message: "#^Parameter \\#1 \\$array of function array_values expects array, mixed given\\.$#" - count: 1 - path: library/Icingadb/Data/VolatileCsvResults.php - - - - message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#" - count: 1 - path: library/Icingadb/Model/Behavior/ActionAndNoteUrl.php - - - - message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, array\\\\|false given\\.$#" - count: 1 - path: library/Icingadb/Model/CustomvarFlat.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, Icinga\\\\Module\\\\Reporting\\\\ReportData\\|null given\\.$#" - count: 1 - path: library/Icingadb/ProvidedHook/Reporting/SlaReport.php - - - - message: "#^Parameter \\#1 \\$num of function number_format expects float, float\\|int\\|string given\\.$#" - count: 1 - path: library/Icingadb/Util/PerfData.php - - - - message: "#^Parameter \\#1 \\$string of function trim expects string, string\\|null given\\.$#" - count: 1 - path: library/Icingadb/Util/PluginOutput.php - - - - message: "#^Parameter \\#1 \\$string of function trim expects string, mixed given\\.$#" - count: 1 - path: library/Icingadb/Web/Controller.php - - - - 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-by-php-version.php b/phpstan-baseline-by-php-version.php deleted file mode 100644 index f338ed829..000000000 --- a/phpstan-baseline-by-php-version.php +++ /dev/null @@ -1,15 +0,0 @@ - -// SPDX-License-Identifier: GPL-3.0-or-later - -$includes = []; -if (PHP_VERSION_ID >= 80000) { - $includes[] = __DIR__ . '/phpstan-baseline-8x.neon'; -} else { - $includes[] = __DIR__ . '/phpstan-baseline-7x.neon'; -} - -return [ - 'includes' => $includes -]; diff --git a/phpstan-baseline-standard.neon b/phpstan-baseline.neon similarity index 95% rename from phpstan-baseline-standard.neon rename to phpstan-baseline.neon index 72c95db90..42e3aea04 100644 --- a/phpstan-baseline-standard.neon +++ b/phpstan-baseline.neon @@ -48,96 +48,12 @@ parameters: count: 2 path: application/controllers/CommandTransportController.php - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:acknowledgeAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/CommentController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:addCommentAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/CommentController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:assertIsGrantedOnCommandTargets\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/CommentController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:checkNowAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/CommentController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:fetchCommandTargets\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: application/controllers/CommentController.php - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:indexAction\(\) has no return type specified\.$#' identifier: missingType.return count: 1 path: application/controllers/CommentController.php - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:processCheckresultAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/CommentController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:removeAcknowledgementAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/CommentController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:scheduleCheckAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/CommentController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:scheduleDowntimeAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/CommentController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:sendCustomNotificationAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/CommentController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:toggleFeaturesAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/CommentController.php - - - - message: '#^Parameter \#1 \$form of method Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:handleCommandForm\(\) expects Icinga\\Module\\Icingadb\\Forms\\Command\\CommandForm\|string, Icinga\\Module\\Icingadb\\Forms\\Command\\Object\\ToggleObjectFeaturesForm\|null given\.$#' - identifier: argument.type - count: 1 - path: application/controllers/CommentController.php - - - - message: '#^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$#' - identifier: argument.type - count: 1 - path: application/controllers/CommentController.php - - - - message: '#^Property Icinga\\Module\\Icingadb\\Controllers\\CommentController\:\:\$commandTargetModel \(ipl\\Orm\\Model\) in isset\(\) is not nullable\.$#' - identifier: isset.property - 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\.$#' identifier: assign.propertyType @@ -204,96 +120,12 @@ parameters: count: 1 path: application/controllers/ConfigController.php - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:acknowledgeAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/DowntimeController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:addCommentAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/DowntimeController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:assertIsGrantedOnCommandTargets\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/DowntimeController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:checkNowAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/DowntimeController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:fetchCommandTargets\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: application/controllers/DowntimeController.php - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:indexAction\(\) has no return type specified\.$#' identifier: missingType.return count: 1 path: application/controllers/DowntimeController.php - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:processCheckresultAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/DowntimeController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:removeAcknowledgementAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/DowntimeController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:scheduleCheckAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/DowntimeController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:scheduleDowntimeAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/DowntimeController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:sendCustomNotificationAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/DowntimeController.php - - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:toggleFeaturesAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: application/controllers/DowntimeController.php - - - - message: '#^Parameter \#1 \$form of method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:handleCommandForm\(\) expects Icinga\\Module\\Icingadb\\Forms\\Command\\CommandForm\|string, Icinga\\Module\\Icingadb\\Forms\\Command\\Object\\ToggleObjectFeaturesForm\|null given\.$#' - identifier: argument.type - count: 1 - path: application/controllers/DowntimeController.php - - - - message: '#^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$#' - identifier: argument.type - count: 1 - path: application/controllers/DowntimeController.php - - - - message: '#^Property Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:\$commandTargetModel \(ipl\\Orm\\Model\) in isset\(\) is not nullable\.$#' - identifier: isset.property - 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\.$#' identifier: assign.propertyType @@ -366,6 +198,12 @@ parameters: count: 1 path: application/controllers/EventController.php + - + message: '#^Parameter \#1 \$string of function hex2bin expects string, mixed given\.$#' + identifier: argument.type + count: 1 + path: application/controllers/EventController.php + - message: '#^Property Icinga\\Module\\Icingadb\\Controllers\\EventController\:\:\$event \(Icinga\\Module\\Icingadb\\Model\\History\) does not accept ipl\\Orm\\Model\.$#' identifier: assign.propertyType @@ -468,12 +306,6 @@ parameters: count: 1 path: application/controllers/HostController.php - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\HostController\:\:fetchCommandTargets\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: application/controllers/HostController.php - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\HostController\:\:processCheckresultAction\(\) has no return type specified\.$#' identifier: missingType.return @@ -546,12 +378,6 @@ parameters: count: 1 path: application/controllers/HostController.php - - - message: '#^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$#' - identifier: argument.type - count: 1 - path: application/controllers/HostController.php - - message: '#^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:lessThanOrEqual\(\) expects float\|int\|string, mixed given\.$#' identifier: argument.type @@ -816,12 +642,6 @@ parameters: count: 1 path: application/controllers/ServiceController.php - - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\ServiceController\:\:fetchCommandTargets\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: application/controllers/ServiceController.php - - message: '#^Method Icinga\\Module\\Icingadb\\Controllers\\ServiceController\:\:processCheckresultAction\(\) has no return type specified\.$#' identifier: missingType.return @@ -906,12 +726,6 @@ parameters: count: 1 path: application/controllers/ServiceController.php - - - message: '#^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$#' - identifier: argument.type - count: 2 - path: application/controllers/ServiceController.php - - message: '#^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:lessThanOrEqual\(\) expects float\|int\|string, mixed given\.$#' identifier: argument.type @@ -1716,6 +1530,12 @@ parameters: count: 1 path: application/forms/RedisConfigForm.php + - + message: '#^Parameter \#1 \$string of function md5 expects string, mixed given\.$#' + identifier: argument.type + count: 1 + path: application/forms/RedisConfigForm.php + - message: '#^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$#' identifier: argument.type @@ -1854,12 +1674,6 @@ parameters: count: 1 path: library/Icingadb/Command/Object/GetObjectCommand.php - - - message: '#^Method Icinga\\Module\\Icingadb\\Command\\Object\\ObjectsCommand\:\:getObjects\(\) return type has no value type specified in iterable type Traversable\.$#' - identifier: missingType.iterableValue - count: 1 - path: library/Icingadb/Command/Object/ObjectsCommand.php - - message: '#^Property Icinga\\Module\\Icingadb\\Command\\Object\\ProcessCheckResultCommand\:\:\$performanceData \(string\) does not accept string\|null\.$#' identifier: assign.propertyType @@ -1920,6 +1734,12 @@ parameters: count: 1 path: library/Icingadb/Command/Transport/ApiCommandTransport.php + - + message: '#^Parameter \#1 \$array of function array_pop expects array, mixed given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/Command/Transport/ApiCommandTransport.php + - message: '#^Property Icinga\\Module\\Icingadb\\Command\\Transport\\CommandTransportConfig\:\:\$configs type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -1939,22 +1759,16 @@ parameters: path: library/Icingadb/Command/Transport/CommandTransportInterface.php - - message: '#^Cannot access offset ''in_downtime'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible + message: '#^Access to constant ATTR_INIT_COMMAND on an unknown class PDO\\Mysql\.$#' + identifier: class.notFound count: 1 - path: library/Icingadb/Common/IcingaRedis.php + path: library/Icingadb/Common/Backend.php - - message: '#^Cannot access offset ''is_acknowledged'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible + message: '#^Possibly invalid array key type mixed\.$#' + identifier: offsetAccess.invalidOffset count: 1 - path: library/Icingadb/Common/IcingaRedis.php - - - - message: '#^Cannot access offset ''state_type'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 2 - path: library/Icingadb/Common/IcingaRedis.php + path: library/Icingadb/Common/Backend.php - message: '#^Method Icinga\\Module\\Icingadb\\Common\\IcingaRedis\:\:fetchHostState\(\) has parameter \$columns with no value type specified in iterable type array\.$#' @@ -1998,6 +1812,12 @@ parameters: count: 1 path: library/Icingadb/Common/IcingaRedis.php + - + message: '#^Parameter \#2 \.\.\.\$arrays of function array_merge expects array, mixed given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/Common/IcingaRedis.php + - message: '#^Method Icinga\\Module\\Icingadb\\Common\\Links\:\:hostgroup\(\) has parameter \$hostgroup with no type specified\.$#' identifier: missingType.parameter @@ -2106,12 +1926,24 @@ parameters: count: 1 path: library/Icingadb/Common/ObjectInspectionDetail.php + - + message: '#^Parameter \#1 \$array of function array_diff_key expects array, mixed given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/Common/ObjectInspectionDetail.php + - message: '#^Parameter \#1 \$content of static method ipl\\Html\\Table\:\:td\(\) expects array\|ipl\\Html\\Html\|string\|null, mixed given\.$#' identifier: argument.type count: 1 path: library/Icingadb/Common/ObjectInspectionDetail.php + - + message: '#^Parameter \#1 \$string of function bin2hex expects string, mixed given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/Common/ObjectInspectionDetail.php + - message: '#^Property Icinga\\Module\\Icingadb\\Common\\ObjectInspectionDetail\:\:\$attrs type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -2226,12 +2058,6 @@ parameters: count: 2 path: library/Icingadb/Compat/CompatHost.php - - - message: '#^Cannot call method columns\(\) on mixed\.$#' - identifier: method.nonObject - count: 1 - path: library/Icingadb/Compat/CompatHost.php - - message: '#^Cannot call method execute\(\) on mixed\.$#' identifier: method.nonObject @@ -2334,12 +2160,6 @@ parameters: count: 2 path: library/Icingadb/Compat/CompatHost.php - - - message: '#^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$#' - identifier: argument.type - count: 3 - path: library/Icingadb/Compat/CompatHost.php - - message: '#^Property Icinga\\Module\\Icingadb\\Compat\\CompatHost\:\:\$legacyColumns has no type specified\.$#' identifier: missingType.property @@ -2358,30 +2178,6 @@ parameters: count: 1 path: library/Icingadb/Compat/CompatHost.php - - - message: '#^Property Icinga\\Module\\Monitoring\\Object\\MonitoredObject\:\:\$eventhistory \(Icinga\\Module\\Monitoring\\DataView\\EventHistory\) does not accept array\.$#' - identifier: assign.propertyType - count: 1 - path: library/Icingadb/Compat/CompatHost.php - - - - message: '#^Property Icinga\\Module\\Monitoring\\Object\\MonitoredObject\:\:\$hostVariables \(array\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: library/Icingadb/Compat/CompatHost.php - - - - message: '#^Property Icinga\\Module\\Monitoring\\Object\\MonitoredObject\:\:\$serviceVariables \(array\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: library/Icingadb/Compat/CompatHost.php - - - - message: '#^Unreachable statement \- code above always terminates\.$#' - identifier: deadCode.unreachable - count: 2 - path: library/Icingadb/Compat/CompatHost.php - - message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#' identifier: foreach.nonIterable @@ -2478,12 +2274,6 @@ parameters: count: 2 path: library/Icingadb/Compat/CompatService.php - - - message: '#^Cannot call method columns\(\) on mixed\.$#' - identifier: method.nonObject - count: 1 - path: library/Icingadb/Compat/CompatService.php - - message: '#^Cannot call method execute\(\) on mixed\.$#' identifier: method.nonObject @@ -2544,12 +2334,6 @@ parameters: count: 1 path: library/Icingadb/Compat/CompatService.php - - - message: '#^Method Icinga\\Module\\Icingadb\\Compat\\CompatService\:\:getHost\(\) should return Icinga\\Module\\Icingadb\\Compat\\CompatHost but returns Icinga\\Module\\Monitoring\\Object\\Host\.$#' - identifier: return.type - count: 1 - path: library/Icingadb/Compat/CompatService.php - - message: '#^Method Icinga\\Module\\Icingadb\\Compat\\CompatService\:\:getName\(\) should return string but returns mixed\.$#' identifier: return.type @@ -2604,12 +2388,6 @@ parameters: count: 2 path: library/Icingadb/Compat/CompatService.php - - - message: '#^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$#' - identifier: argument.type - count: 3 - path: library/Icingadb/Compat/CompatService.php - - message: '#^Property Icinga\\Module\\Icingadb\\Compat\\CompatService\:\:\$legacyColumns has no type specified\.$#' identifier: missingType.property @@ -2628,30 +2406,6 @@ parameters: count: 1 path: library/Icingadb/Compat/CompatService.php - - - message: '#^Property Icinga\\Module\\Monitoring\\Object\\MonitoredObject\:\:\$eventhistory \(Icinga\\Module\\Monitoring\\DataView\\EventHistory\) does not accept array\.$#' - identifier: assign.propertyType - count: 1 - path: library/Icingadb/Compat/CompatService.php - - - - message: '#^Property Icinga\\Module\\Monitoring\\Object\\MonitoredObject\:\:\$hostVariables \(array\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: library/Icingadb/Compat/CompatService.php - - - - message: '#^Property Icinga\\Module\\Monitoring\\Object\\MonitoredObject\:\:\$serviceVariables \(array\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: library/Icingadb/Compat/CompatService.php - - - - message: '#^Unreachable statement \- code above always terminates\.$#' - identifier: deadCode.unreachable - count: 2 - path: library/Icingadb/Compat/CompatService.php - - message: '#^Method Icinga\\Module\\Icingadb\\Compat\\UrlMigrator\:\:commentsColumns\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -2785,9 +2539,9 @@ parameters: path: library/Icingadb/Compat/UrlMigrator.php - - message: '#^Parameter \#1 \$column of method ipl\\Stdlib\\Filter\\Condition\:\:setColumn\(\) expects string, int\|string\|null given\.$#' + message: '#^Parameter \#1 \$string of function strtolower expects string, mixed given\.$#' identifier: argument.type - count: 1 + count: 2 path: library/Icingadb/Compat/UrlMigrator.php - @@ -2802,6 +2556,12 @@ parameters: count: 1 path: library/Icingadb/Data/CsvResultSet.php + - + message: '#^Parameter \#1 \$array of function array_keys expects array, mixed given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/Data/CsvResultSet.php + - message: '#^Parameter \#1 \$key of method Icinga\\Module\\Icingadb\\Data\\CsvResultSet\:\:formatValue\(\) expects string, mixed given\.$#' identifier: argument.type @@ -2868,6 +2628,12 @@ parameters: count: 1 path: library/Icingadb/Data/PivotTable.php + - + message: '#^Parameter \#2 \$string of function explode expects string, mixed given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/Data/PivotTable.php + - message: '#^Property Icinga\\Module\\Icingadb\\Data\\PivotTable\:\:\$gridcols type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -2904,6 +2670,12 @@ parameters: count: 1 path: library/Icingadb/Data/VolatileCsvResults.php + - + message: '#^Parameter \#1 \$array of function array_keys expects array, mixed given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/Data/VolatileCsvResults.php + - message: '#^Parameter \#1 \$key of method Icinga\\Module\\Icingadb\\Data\\VolatileCsvResults\:\:formatValue\(\) expects string, mixed given\.$#' identifier: argument.type @@ -3108,6 +2880,12 @@ parameters: count: 1 path: library/Icingadb/Model/Behavior/ActionAndNoteUrl.php + - + message: '#^Parameter \#2 \$string of function explode expects string, mixed given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/Model/Behavior/ActionAndNoteUrl.php + - message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#' identifier: foreach.nonIterable @@ -3198,12 +2976,6 @@ parameters: count: 1 path: library/Icingadb/Model/Behavior/FlattenedObjectVars.php - - - message: '#^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$#' - identifier: argument.type - count: 1 - path: library/Icingadb/Model/Behavior/FlattenedObjectVars.php - - message: '#^Part \$column \(mixed\) of encapsed string cannot be cast to string\.$#' identifier: encapsedStringPart.nonString @@ -4806,6 +4578,12 @@ parameters: count: 1 path: library/Icingadb/ProvidedHook/Reporting/SlaReport.php + - + message: '#^Parameter \#1 \$value of function count expects array\|Countable, Icinga\\Module\\Reporting\\ReportData\|null given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/ProvidedHook/Reporting/SlaReport.php + - message: '#^Parameter \#2 \$end of class Icinga\\Module\\Reporting\\Timerange constructor expects DateTime, mixed given\.$#' identifier: argument.type @@ -5280,6 +5058,12 @@ parameters: count: 1 path: library/Icingadb/Util/PerfData.php + - + message: '#^Parameter \#1 \$num of function number_format expects float, float\|int\|string given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/Util/PerfData.php + - message: '#^Parameter \#1 \$value of method Icinga\\Module\\Icingadb\\Util\\ThresholdRange\:\:contains\(\) expects float, float\|null given\.$#' identifier: argument.type @@ -5496,6 +5280,12 @@ parameters: count: 1 path: library/Icingadb/Util/PluginOutput.php + - + message: '#^Parameter \#1 \$string of function trim expects string, string\|null given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/Util/PluginOutput.php + - message: '#^Property Icinga\\Module\\Icingadb\\Util\\PluginOutput\:\:\$renderedOutput \(string\) does not accept string\|null\.$#' identifier: assign.propertyType @@ -5574,12 +5364,6 @@ parameters: count: 1 path: library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php - - - message: '#^Cannot access property \$flatname on array\\.$#' - identifier: property.nonObject - count: 1 - path: library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php - - message: '#^Cannot call method getRoles\(\) on Icinga\\User\|null\.$#' identifier: method.nonObject @@ -5850,12 +5634,6 @@ parameters: count: 1 path: library/Icingadb/Web/Controller.php - - - message: '#^Method Icinga\\Module\\Icingadb\\Web\\Controller\:\:sendAsPdf\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: library/Icingadb/Web/Controller.php - - message: '#^PHPDoc tag @param references unknown parameter\: \$preserveParams$#' identifier: parameter.notFound @@ -5898,6 +5676,18 @@ parameters: count: 3 path: library/Icingadb/Web/Controller.php + - + message: '#^Parameter \#1 \$string of function trim expects string, mixed given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/Web/Controller.php + + - + message: '#^Parameter \#2 \$string of function explode expects string, mixed given\.$#' + identifier: argument.type + count: 1 + path: library/Icingadb/Web/Controller.php + - message: '#^Parameter \#2 \$tableName of method ipl\\Orm\\Resolver\:\:qualifyColumn\(\) expects string, int\\|int\<1, max\>\|string given\.$#' identifier: argument.type @@ -6396,12 +6186,6 @@ parameters: count: 1 path: library/Icingadb/Widget/Detail/CustomVarTable.php - - - message: '#^Parameter \#2 \$value of method ipl\\Html\\Attributes\:\:add\(\) expects array\|bool\|string\|null, int given\.$#' - identifier: argument.type - count: 1 - path: library/Icingadb/Widget/Detail/CustomVarTable.php - - message: '#^Property Icinga\\Module\\Icingadb\\Widget\\Detail\\CustomVarTable\:\:\$data \(array\) does not accept iterable\.$#' identifier: assign.propertyType @@ -7128,12 +6912,6 @@ parameters: count: 3 path: library/Icingadb/Widget/Detail/ObjectDetail.php - - - message: '#^Parameter \#1 \$view of method Icinga\\Module\\Monitoring\\Hook\\DetailviewExtensionHook\:\:setView\(\) expects Icinga\\Web\\View, null given\.$#' - identifier: argument.type - count: 1 - path: library/Icingadb/Widget/Detail/ObjectDetail.php - - message: '#^Parameter \#2 \$tableName of method ipl\\Orm\\Resolver\:\:qualifyColumn\(\) expects string, int\\|int\<1, max\>\|string given\.$#' identifier: argument.type @@ -7146,12 +6924,6 @@ parameters: count: 2 path: library/Icingadb/Widget/Detail/ObjectDetail.php - - - message: '#^Possibly invalid array key type array\|bool\|string\|null\.$#' - identifier: offsetAccess.invalidOffset - count: 1 - path: library/Icingadb/Widget/Detail/ObjectDetail.php - - message: '#^Property Icinga\\Module\\Icingadb\\Widget\\Detail\\ObjectDetail\:\:\$compatObject has no type specified\.$#' identifier: missingType.property diff --git a/phpstan.neon b/phpstan.neon index a0656a4bf..453c53894 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,5 @@ includes: - - phpstan-baseline-standard.neon - - phpstan-baseline-by-php-version.php + - phpstan-baseline.neon parameters: level: max