GraphingTrait: Define config value type

This commit is contained in:
Johannes Meyer 2024-02-15 14:05:20 +01:00
parent 254ff35b31
commit f4cdeee6f0
2 changed files with 14 additions and 82 deletions

View file

@ -4,6 +4,7 @@ namespace Icinga\Module\Graphite\Graphing;
use Icinga\Application\Config;
use Icinga\Application\Icinga;
use Icinga\Data\ConfigObject;
use Icinga\Exception\ConfigurationError;
use Icinga\Module\Graphite\Web\FakeSchemeRequest;
use Icinga\Web\Url;
@ -61,6 +62,7 @@ trait GraphingTrait
{
if (static::$metricsDataSource === null) {
$config = Config::module('graphite');
/** @var ConfigObject<string> $graphite */
$graphite = $config->getSection('graphite');
if (! isset($graphite->url)) {
throw new ConfigurationError('Missing "graphite.url" in "%s"', $config->getConfigFile());
@ -70,7 +72,7 @@ trait GraphingTrait
(new GraphiteWebClient(Url::fromPath($graphite->url, [], new FakeSchemeRequest())))
->setUser($graphite->user)
->setPassword($graphite->password)
->setInsecure($graphite->insecure)
->setInsecure((bool) $graphite->insecure)
);
}

View file

@ -15,26 +15,6 @@ parameters:
count: 1
path: application/clicommands/Icinga2Command.php
-
message: "#^Parameter \\#1 \\$insecure of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\GraphiteWebClient\\:\\:setInsecure\\(\\) expects bool, mixed given\\.$#"
count: 1
path: application/clicommands/Icinga2Command.php
-
message: "#^Parameter \\#1 \\$password of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\GraphiteWebClient\\:\\:setPassword\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
path: application/clicommands/Icinga2Command.php
-
message: "#^Parameter \\#1 \\$url of static method Icinga\\\\Web\\\\Url\\:\\:fromPath\\(\\) expects string, mixed given\\.$#"
count: 1
path: application/clicommands/Icinga2Command.php
-
message: "#^Parameter \\#1 \\$user of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\GraphiteWebClient\\:\\:setUser\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
path: application/clicommands/Icinga2Command.php
-
message: "#^Method Icinga\\\\Module\\\\Graphite\\\\Controllers\\\\ConfigController\\:\\:advancedAction\\(\\) has no return type specified\\.$#"
count: 1
@ -65,26 +45,6 @@ parameters:
count: 1
path: application/controllers/GraphController.php
-
message: "#^Parameter \\#1 \\$insecure of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\GraphiteWebClient\\:\\:setInsecure\\(\\) expects bool, mixed given\\.$#"
count: 1
path: application/controllers/GraphController.php
-
message: "#^Parameter \\#1 \\$password of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\GraphiteWebClient\\:\\:setPassword\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
path: application/controllers/GraphController.php
-
message: "#^Parameter \\#1 \\$url of static method Icinga\\\\Web\\\\Url\\:\\:fromPath\\(\\) expects string, mixed given\\.$#"
count: 1
path: application/controllers/GraphController.php
-
message: "#^Parameter \\#1 \\$user of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\GraphiteWebClient\\:\\:setUser\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
path: application/controllers/GraphController.php
-
message: "#^Parameter \\#2 \\$checkCommand of method Icinga\\\\Module\\\\Graphite\\\\Controllers\\\\GraphController\\:\\:supplyImage\\(\\) expects string, mixed given\\.$#"
count: 2
@ -190,26 +150,6 @@ parameters:
count: 1
path: application/controllers/MonitoringGraphController.php
-
message: "#^Parameter \\#1 \\$insecure of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\GraphiteWebClient\\:\\:setInsecure\\(\\) expects bool, mixed given\\.$#"
count: 1
path: application/controllers/MonitoringGraphController.php
-
message: "#^Parameter \\#1 \\$password of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\GraphiteWebClient\\:\\:setPassword\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
path: application/controllers/MonitoringGraphController.php
-
message: "#^Parameter \\#1 \\$url of static method Icinga\\\\Web\\\\Url\\:\\:fromPath\\(\\) expects string, mixed given\\.$#"
count: 1
path: application/controllers/MonitoringGraphController.php
-
message: "#^Parameter \\#1 \\$user of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\GraphiteWebClient\\:\\:setUser\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
path: application/controllers/MonitoringGraphController.php
-
message: "#^Parameter \\#2 \\$host of class Icinga\\\\Module\\\\Monitoring\\\\Object\\\\Host constructor expects string, mixed given\\.$#"
count: 1
@ -460,6 +400,11 @@ parameters:
count: 2
path: library/Graphite/Graphing/Template.php
-
message: "#^PHPDoc tag @var for variable \\$options contains generic class Icinga\\\\Data\\\\ConfigObject but does not specify its types\\: TValue$#"
count: 1
path: library/Graphite/Graphing/Templates.php
-
message: "#^Parameter \\#1 \\$array of function array_unique expects array, array\\<int, string\\>\\|false given\\.$#"
count: 1
@ -472,7 +417,7 @@ parameters:
-
message: "#^Parameter \\#1 \\$template of class Icinga\\\\Module\\\\Graphite\\\\Util\\\\MacroTemplate constructor expects string, mixed given\\.$#"
count: 1
count: 4
path: library/Graphite/Graphing/Templates.php
-
@ -480,6 +425,11 @@ parameters:
count: 1
path: library/Graphite/Graphing/Templates.php
-
message: "#^Parameter \\#2 \\$subject of function preg_split expects string, mixed given\\.$#"
count: 1
path: library/Graphite/Graphing/Templates.php
-
message: "#^Property Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\Templates\\:\\:\\$defaultTemplates \\(array\\<Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\Template\\>\\) does not accept array\\<array\\<array\\>\\|Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\Template\\>\\.$#"
count: 1
@ -710,26 +660,6 @@ parameters:
count: 1
path: library/Graphite/Web/Widget/Graphs.php
-
message: "#^Parameter \\#1 \\$insecure of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\GraphiteWebClient\\:\\:setInsecure\\(\\) expects bool, mixed given\\.$#"
count: 1
path: library/Graphite/Web/Widget/Graphs.php
-
message: "#^Parameter \\#1 \\$password of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\GraphiteWebClient\\:\\:setPassword\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
path: library/Graphite/Web/Widget/Graphs.php
-
message: "#^Parameter \\#1 \\$url of static method Icinga\\\\Web\\\\Url\\:\\:fromPath\\(\\) expects string, mixed given\\.$#"
count: 1
path: library/Graphite/Web/Widget/Graphs.php
-
message: "#^Parameter \\#1 \\$user of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\GraphiteWebClient\\:\\:setUser\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
path: library/Graphite/Web/Widget/Graphs.php
-
message: "#^Part \\$relative \\(mixed\\) of encapsed string cannot be cast to string\\.$#"
count: 1