Skip to content

Commit

Permalink
GraphingTrait: Define config value type
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed Feb 15, 2024
1 parent 254ff35 commit 9166166
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 82 deletions.
4 changes: 3 additions & 1 deletion library/Graphite/Graphing/GraphingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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;
Expand Down Expand Up @@ -61,6 +62,7 @@ public static function getMetricsDataSource()
{
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());
Expand All @@ -70,7 +72,7 @@ public static function getMetricsDataSource()
(new GraphiteWebClient(Url::fromPath($graphite->url, [], new FakeSchemeRequest())))
->setUser($graphite->user)
->setPassword($graphite->password)
->setInsecure($graphite->insecure)
->setInsecure((bool) $graphite->insecure)
);
}

Expand Down
92 changes: 11 additions & 81 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -472,14 +417,19 @@ 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

-
message: "#^Parameter \\#1 \\$urlParams of method Icinga\\\\Module\\\\Graphite\\\\Graphing\\\\Template\\:\\:setUrlParams\\(\\) expects array\\<Icinga\\\\Module\\\\Graphite\\\\Util\\\\MacroTemplate\\>, array\\<Icinga\\\\Module\\\\Graphite\\\\Util\\\\MacroTemplate\\|string\\> given\\.$#"
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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9166166

Please sign in to comment.