diff --git a/application/clicommands/MigrateCommand.php b/application/clicommands/MigrateCommand.php index c5eb8fbf..b5accb8c 100644 --- a/application/clicommands/MigrateCommand.php +++ b/application/clicommands/MigrateCommand.php @@ -787,7 +787,7 @@ class MigrateCommand extends Command 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 cfaa0750..ef911c1d 100644 --- a/application/forms/RedisConfigForm.php +++ b/application/forms/RedisConfigForm.php @@ -676,13 +676,13 @@ class RedisConfigForm extends ConfigForm * 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 875a5f18..d63912c1 100644 --- a/library/Icingadb/Command/Object/ProcessCheckResultCommand.php +++ b/library/Icingadb/Command/Object/ProcessCheckResultCommand.php @@ -118,11 +118,11 @@ class ProcessCheckResultCommand extends ObjectsCommand /** * 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 3857d865..1d8f497a 100644 --- a/library/Icingadb/Command/Transport/ApiCommandTransport.php +++ b/library/Icingadb/Command/Transport/ApiCommandTransport.php @@ -301,13 +301,13 @@ class ApiCommandTransport implements CommandTransportInterface * 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 75cad032..03358a1e 100644 --- a/library/Icingadb/Command/Transport/CommandTransport.php +++ b/library/Icingadb/Command/Transport/CommandTransport.php @@ -94,14 +94,14 @@ class CommandTransport implements CommandTransportInterface * * 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 48423461..ac5dc642 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 06b6dad5..cf2840c5 100644 --- a/library/Icingadb/Common/HostStates.php +++ b/library/Icingadb/Common/HostStates.php @@ -47,13 +47,13 @@ class HostStates /** * 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 @@ class HostStates /** * 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 231ecc01..3e9a1293 100644 --- a/library/Icingadb/Common/IcingaRedis.php +++ b/library/Icingadb/Common/IcingaRedis.php @@ -173,11 +173,11 @@ class IcingaRedis /** * 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 @@ class IcingaRedis /** * 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 @@ class IcingaRedis /** * 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 68aea14c..5dd6b114 100644 --- a/library/Icingadb/Common/ServiceStates.php +++ b/library/Icingadb/Common/ServiceStates.php @@ -57,13 +57,13 @@ class ServiceStates /** * 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 @@ class ServiceStates /** * 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 eaa246e5..f30226f6 100644 --- a/library/Icingadb/Common/StateBadges.php +++ b/library/Icingadb/Common/StateBadges.php @@ -118,7 +118,7 @@ abstract class StateBadges extends BaseHtmlElement * * @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 8d5321c2..62e9ac5c 100644 --- a/library/Icingadb/Compat/UrlMigrator.php +++ b/library/Icingadb/Compat/UrlMigrator.php @@ -84,7 +84,7 @@ class UrlMigrator 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 @@ class UrlMigrator * 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 2e75a5c8..4613c355 100644 --- a/library/Icingadb/Data/PivotTable.php +++ b/library/Icingadb/Data/PivotTable.php @@ -115,11 +115,11 @@ class PivotTable /** * 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 @@ class PivotTable /** * 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 @@ class PivotTable /** * 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 @@ class PivotTable * * $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 @@ class PivotTable * * $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 687c0c0f..5ae5dcb1 100644 --- a/library/Icingadb/Hook/Common/TotalSlaReportUtils.php +++ b/library/Icingadb/Hook/Common/TotalSlaReportUtils.php @@ -14,7 +14,7 @@ use function ipl\I18n\t; 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 acb9dc37..0d634f49 100644 --- a/library/Icingadb/Model/UnreachableParent.php +++ b/library/Icingadb/Model/UnreachableParent.php @@ -86,7 +86,7 @@ class UnreachableParent extends DependencyNode ])); } - 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 d12d646a..e975545c 100644 --- a/library/Icingadb/ProvidedHook/Reporting/HostSlaReport.php +++ b/library/Icingadb/ProvidedHook/Reporting/HostSlaReport.php @@ -45,7 +45,7 @@ class HostSlaReport extends SlaReport ->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 4b118050..fb281d5c 100644 --- a/library/Icingadb/ProvidedHook/Reporting/ServiceSlaReport.php +++ b/library/Icingadb/ProvidedHook/Reporting/ServiceSlaReport.php @@ -45,7 +45,7 @@ class ServiceSlaReport extends SlaReport ->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 0d4cae36..6e3bb81d 100644 --- a/library/Icingadb/ProvidedHook/Reporting/SlaReport.php +++ b/library/Icingadb/ProvidedHook/Reporting/SlaReport.php @@ -56,13 +56,13 @@ abstract class SlaReport extends ReportHook * 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 @@ abstract class SlaReport extends ReportHook ]); } - 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 eab1946c..5de953cc 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 19c4b9af..f4303ecc 100644 --- a/library/Icingadb/Util/PerfDataSet.php +++ b/library/Icingadb/Util/PerfDataSet.php @@ -135,11 +135,11 @@ class PerfDataSet implements IteratorAggregate * 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 45429e2d..ea045aa7 100644 --- a/library/Icingadb/Web/Controller.php +++ b/library/Icingadb/Web/Controller.php @@ -319,11 +319,11 @@ class Controller extends CompatController /** * 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 @@ class Controller extends CompatController 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 85a8b01c..db1fc13e 100644 --- a/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php +++ b/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php @@ -115,7 +115,7 @@ abstract class ProblemsBadge extends NavigationItemRenderer 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 e2265e0e..67359e09 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 4558c50d..faaf6f50 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 45c32911..4aad786c 100644 --- a/test/php/library/Icingadb/Common/StateBadgesTest.php +++ b/test/php/library/Icingadb/Common/StateBadgesTest.php @@ -84,7 +84,7 @@ class StateBadgesTest extends TestCase 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); }