Phpstan: Create php version based baseline

This commit is contained in:
Sukhwinder Dhillon 2024-01-23 11:45:47 +01:00 committed by Johannes Meyer
parent aba7e46f49
commit ddd7a4ff8a
5 changed files with 311 additions and 146 deletions

151
phpstan-baseline-7x.neon Normal file
View file

@ -0,0 +1,151 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$data of function hex2bin expects string, mixed given\\.$#"
count: 1
path: application/controllers/EventController.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/AcknowledgeProblemForm.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/AddCommentForm.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#"
count: 1
path: application/forms/Command/Object/CheckNowForm.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/DeleteCommentForm.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/DeleteDowntimeForm.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/ProcessCheckResultForm.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/RemoveAcknowledgementForm.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/ScheduleCheckForm.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#"
count: 1
path: application/forms/Command/Object/ScheduleHostDowntimeForm.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/ScheduleServiceDowntimeForm.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/SendCustomNotificationForm.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 \\#1 \\$str of function strtolower expects string, mixed given\\.$#"
count: 1
path: library/Icingadb/Command/Transport/CommandTransport.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 \\#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\\<int, string\\>\\|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

146
phpstan-baseline-8x.neon Normal file
View file

@ -0,0 +1,146 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$string of function hex2bin expects string, mixed given\\.$#"
count: 1
path: application/controllers/EventController.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/AcknowledgeProblemForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/AddCommentForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 1
path: application/forms/Command/Object/CheckNowForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/DeleteCommentForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/DeleteDowntimeForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/ProcessCheckResultForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/RemoveAcknowledgementForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/ScheduleCheckForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 1
path: application/forms/Command/Object/ScheduleHostDowntimeForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/ScheduleServiceDowntimeForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/SendCustomNotificationForm.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 \\#1 \\$string of function strtolower expects string, mixed given\\.$#"
count: 1
path: library/Icingadb/Command/Transport/CommandTransport.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 \\#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\\<int, string\\>\\|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

View file

@ -0,0 +1,12 @@
<?php
$includes = [];
if (PHP_VERSION_ID >= 80000) {
$includes[] = __DIR__ . '/phpstan-baseline-8x.neon';
} else {
$includes[] = __DIR__ . '/phpstan-baseline-7x.neon';
}
return [
'includes' => $includes
];

View file

@ -330,11 +330,6 @@ parameters:
count: 1
path: application/controllers/EventController.php
-
message: "#^Parameter \\#1 \\$string of function hex2bin expects string, mixed given\\.$#"
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\\|null\\.$#"
count: 1
@ -1340,11 +1335,6 @@ parameters:
count: 1
path: application/forms/Command/Object/AcknowledgeProblemForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/AcknowledgeProblemForm.php
-
message: "#^Call to an undefined method ipl\\\\Html\\\\Contract\\\\FormElement\\:\\:isChecked\\(\\)\\.$#"
count: 1
@ -1370,26 +1360,11 @@ parameters:
count: 1
path: application/forms/Command/Object/AddCommentForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/AddCommentForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 1
path: application/forms/Command/Object/CheckNowForm.php
-
message: "#^Cannot call method getUsername\\(\\) on Icinga\\\\User\\|null\\.$#"
count: 1
path: application/forms/Command/Object/DeleteCommentForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/DeleteCommentForm.php
-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 1
@ -1405,11 +1380,6 @@ parameters:
count: 1
path: application/forms/Command/Object/DeleteDowntimeForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/DeleteDowntimeForm.php
-
message: "#^Cannot access property \\$passive_checks_enabled on mixed\\.$#"
count: 1
@ -1440,11 +1410,6 @@ parameters:
count: 1
path: application/forms/Command/Object/ProcessCheckResultForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/ProcessCheckResultForm.php
-
message: "#^Cannot call method getUsername\\(\\) on Icinga\\\\User\\|null\\.$#"
count: 1
@ -1455,11 +1420,6 @@ parameters:
count: 1
path: application/forms/Command/Object/RemoveAcknowledgementForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/RemoveAcknowledgementForm.php
-
message: "#^Call to an undefined method ipl\\\\Html\\\\Contract\\\\FormElement\\:\\:isChecked\\(\\)\\.$#"
count: 1
@ -1475,11 +1435,6 @@ parameters:
count: 1
path: application/forms/Command/Object/ScheduleCheckForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/ScheduleCheckForm.php
-
message: "#^Call to an undefined method ipl\\\\Html\\\\Contract\\\\FormElement\\:\\:isChecked\\(\\)\\.$#"
count: 2
@ -1510,11 +1465,6 @@ parameters:
count: 3
path: application/forms/Command/Object/ScheduleHostDowntimeForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 1
path: application/forms/Command/Object/ScheduleHostDowntimeForm.php
-
message: "#^Call to an undefined method ipl\\\\Html\\\\Contract\\\\FormElement\\:\\:isChecked\\(\\)\\.$#"
count: 1
@ -1545,11 +1495,6 @@ parameters:
count: 3
path: application/forms/Command/Object/ScheduleServiceDowntimeForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/ScheduleServiceDowntimeForm.php
-
message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Forms\\\\Command\\\\Object\\\\ScheduleServiceDowntimeForm\\:\\:\\$flexibleEnd has no type specified\\.$#"
count: 1
@ -1575,11 +1520,6 @@ parameters:
count: 1
path: application/forms/Command/Object/SendCustomNotificationForm.php
-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
count: 2
path: application/forms/Command/Object/SendCustomNotificationForm.php
-
message: "#^Cannot call method getAttributes\\(\\) on ipl\\\\Html\\\\Contract\\\\Wrappable\\|null\\.$#"
count: 1
@ -1810,11 +1750,6 @@ parameters:
count: 1
path: application/forms/RedisConfigForm.php
-
message: "#^Parameter \\#1 \\$string of function md5 expects string, mixed given\\.$#"
count: 1
path: application/forms/RedisConfigForm.php
-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
count: 1
@ -2010,16 +1945,6 @@ parameters:
count: 1
path: library/Icingadb/Command/Transport/ApiCommandTransport.php
-
message: "#^Parameter \\#1 \\$array of function array_pop expects array, mixed given\\.$#"
count: 1
path: library/Icingadb/Command/Transport/ApiCommandTransport.php
-
message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#"
count: 1
path: library/Icingadb/Command/Transport/CommandTransport.php
-
message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Command\\\\Transport\\\\CommandTransportConfig\\:\\:\\$configs type has no value type specified in iterable type array\\.$#"
count: 1
@ -2085,11 +2010,6 @@ parameters:
count: 1
path: library/Icingadb/Common/IcingaRedis.php
-
message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, mixed given\\.$#"
count: 1
path: library/Icingadb/Common/IcingaRedis.php
-
message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Common\\\\Links\\:\\:hostgroup\\(\\) has parameter \\$hostgroup with no type specified\\.$#"
count: 1
@ -2180,21 +2100,11 @@ parameters:
count: 1
path: library/Icingadb/Common/ObjectInspectionDetail.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 \\$content of static method ipl\\\\Html\\\\Table\\:\\:td\\(\\) expects array\\|ipl\\\\Html\\\\Html\\|string\\|null, 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: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Common\\\\ObjectInspectionDetail\\:\\:\\$attrs type has no value type specified in iterable type array\\.$#"
count: 1
@ -2780,11 +2690,6 @@ parameters:
count: 1
path: library/Icingadb/Compat/UrlMigrator.php
-
message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#"
count: 2
path: library/Icingadb/Compat/UrlMigrator.php
-
message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Data\\\\CsvResultSet\\:\\:extractKeysAndValues\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
@ -2795,16 +2700,6 @@ parameters:
count: 1
path: library/Icingadb/Data/CsvResultSet.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 \\#1 \\$key of method Icinga\\\\Module\\\\Icingadb\\\\Data\\\\CsvResultSet\\:\\:formatValue\\(\\) expects string, mixed given\\.$#"
count: 1
@ -2855,11 +2750,6 @@ parameters:
count: 1
path: library/Icingadb/Data/PivotTable.php
-
message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#"
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\\.$#"
count: 1
@ -3055,11 +2945,6 @@ parameters:
count: 1
path: library/Icingadb/Model/Behavior/ActionAndNoteUrl.php
-
message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#"
count: 1
path: library/Icingadb/Model/Behavior/ActionAndNoteUrl.php
-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 1
@ -3340,11 +3225,6 @@ parameters:
count: 1
path: library/Icingadb/Model/CustomvarFlat.php
-
message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, array\\<int, string\\>\\|false given\\.$#"
count: 1
path: library/Icingadb/Model/CustomvarFlat.php
-
message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Model\\\\Downtime\\:\\:createBehaviors\\(\\) has no return type specified\\.$#"
count: 1
@ -4535,11 +4415,6 @@ 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\\.$#"
count: 1
path: library/Icingadb/ProvidedHook/Reporting/SlaReport.php
-
message: "#^Parameter \\#2 \\$array of function join expects array\\<string\\>, array\\<int, \\(Closure\\)\\|string\\> given\\.$#"
count: 1
@ -4965,11 +4840,6 @@ parameters:
count: 1
path: library/Icingadb/Util/PerfData.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 \\$value of method Icinga\\\\Module\\\\Icingadb\\\\Util\\\\ThresholdRange\\:\\:contains\\(\\) expects float, float\\|null given\\.$#"
count: 2
@ -5180,11 +5050,6 @@ parameters:
count: 2
path: library/Icingadb/Util/PluginOutput.php
-
message: "#^Parameter \\#1 \\$string of function trim expects string, string\\|null given\\.$#"
count: 1
path: library/Icingadb/Util/PluginOutput.php
-
message: "#^Parameter \\#2 \\$subject of function preg_match expects string, string\\|null given\\.$#"
count: 1
@ -5545,21 +5410,11 @@ parameters:
count: 3
path: library/Icingadb/Web/Controller.php
-
message: "#^Parameter \\#1 \\$string of function trim expects string, mixed given\\.$#"
count: 1
path: library/Icingadb/Web/Controller.php
-
message: "#^Parameter \\#2 \\$array of function join expects array\\<string\\>, array\\<int, \\(Closure\\)\\|string\\> 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 \\#2 \\$tableName of method ipl\\\\Orm\\\\Resolver\\:\\:qualifyColumn\\(\\) expects string, int\\<min, \\-1\\>\\|int\\<1, max\\>\\|string given\\.$#"
count: 4

View file

@ -1,5 +1,6 @@
includes:
- phpstan-baseline.neon
- phpstan-baseline-standard.neon
- phpstan-baseline-by-php-version.php
parameters:
level: max