From 087b1b6c8ef30600d218c254ec6576abca60c894 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 26 Mar 2024 11:43:52 +0100 Subject: [PATCH] phpstan: Separate baseline by php version --- phpstan-baseline-7x.neon | 81 ++++++++++++ phpstan-baseline-8x.neon | 81 ++++++++++++ phpstan-baseline-by-php-version.php | 12 ++ ...ine.neon => phpstan-baseline-standard.neon | 125 ++---------------- phpstan.neon | 3 +- 5 files changed, 186 insertions(+), 116 deletions(-) create mode 100644 phpstan-baseline-7x.neon create mode 100644 phpstan-baseline-8x.neon create mode 100644 phpstan-baseline-by-php-version.php rename phpstan-baseline.neon => phpstan-baseline-standard.neon (97%) diff --git a/phpstan-baseline-7x.neon b/phpstan-baseline-7x.neon new file mode 100644 index 00000000..0da77d7d --- /dev/null +++ b/phpstan-baseline-7x.neon @@ -0,0 +1,81 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\#1 \\$fp of function fpassthru expects resource, resource\\|false given\\.$#" + count: 1 + path: application/controllers/ProcessController.php + + - + message: "#^Parameter \\#1 \\$fp of function fputcsv expects resource, resource\\|false given\\.$#" + count: 2 + path: application/controllers/ProcessController.php + + - + message: "#^Parameter \\#1 \\$fp of function rewind expects resource, resource\\|false given\\.$#" + count: 1 + path: application/controllers/ProcessController.php + + - + message: "#^Parameter \\#1 \\$str of function strtolower expects string, mixed given\\.$#" + count: 1 + path: application/controllers/ProcessController.php + + - + message: "#^Parameter \\#2 \\$args of function vsprintf expects array\\, array\\ given\\.$#" + count: 2 + path: library/Businessprocess/BpConfig.php + + - + message: "#^Parameter \\#2 \\$search of function array_key_exists expects array, array\\\\|null given\\.$#" + count: 1 + path: library/Businessprocess/BpNode.php + + - + message: "#^Parameter \\#1 \\$str of function ucfirst expects string, mixed given\\.$#" + count: 1 + path: library/Businessprocess/Modification/NodeAction.php + + - + message: "#^Parameter \\#2 \\$search of function array_key_exists expects array, mixed given\\.$#" + count: 1 + path: library/Businessprocess/Monitoring/Backend/Ido/Query/HostStatusQuery.php + + - + message: "#^Parameter \\#2 \\$search of function array_key_exists expects array, mixed given\\.$#" + count: 1 + path: library/Businessprocess/Monitoring/Backend/Ido/Query/ServiceStatusQuery.php + + - + message: "#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, mixed given\\.$#" + count: 2 + path: library/Businessprocess/State/IcingaDbState.php + + - + message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#" + count: 1 + path: library/Businessprocess/Storage/LegacyConfigParser.php + + - + message: "#^Parameter \\#1 \\$fp of function fgets expects resource, resource\\|false given\\.$#" + count: 1 + path: library/Businessprocess/Storage/LegacyConfigParser.php + + - + message: "#^Parameter \\#1 \\$stack of function array_shift expects array, array\\\\|false given\\.$#" + count: 1 + path: library/Businessprocess/Storage/LegacyConfigParser.php + + - + message: "#^Parameter \\#2 \\$args of function vsprintf expects array\\, array\\ given\\.$#" + count: 1 + path: library/Businessprocess/Web/Controller.php + + - + message: "#^Parameter \\#1 \\$stack of function array_pop expects array, array\\\\|false given\\.$#" + count: 1 + path: library/Businessprocess/Web/Form/FormLoader.php + + - + message: "#^Parameter \\#1 \\$stack of function array_pop expects array, array\\\\|false given\\.$#" + count: 1 + path: library/Businessprocess/Web/Form/QuickForm.php diff --git a/phpstan-baseline-8x.neon b/phpstan-baseline-8x.neon new file mode 100644 index 00000000..bb0184b2 --- /dev/null +++ b/phpstan-baseline-8x.neon @@ -0,0 +1,81 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\#1 \\$stream of function fpassthru expects resource, resource\\|false given\\.$#" + count: 1 + path: application/controllers/ProcessController.php + + - + message: "#^Parameter \\#1 \\$stream of function fputcsv expects resource, resource\\|false given\\.$#" + count: 2 + path: application/controllers/ProcessController.php + + - + message: "#^Parameter \\#1 \\$stream of function rewind expects resource, resource\\|false given\\.$#" + count: 1 + path: application/controllers/ProcessController.php + + - + message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#" + count: 1 + path: application/controllers/ProcessController.php + + - + message: "#^Parameter \\#2 \\$values of function vsprintf expects array\\, array\\ given\\.$#" + count: 2 + path: library/Businessprocess/BpConfig.php + + - + message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, array\\\\|null given\\.$#" + count: 1 + path: library/Businessprocess/BpNode.php + + - + message: "#^Parameter \\#1 \\$string of function ucfirst expects string, mixed given\\.$#" + count: 1 + path: library/Businessprocess/Modification/NodeAction.php + + - + message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, mixed given\\.$#" + count: 1 + path: library/Businessprocess/Monitoring/Backend/Ido/Query/HostStatusQuery.php + + - + message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, mixed given\\.$#" + count: 1 + path: library/Businessprocess/Monitoring/Backend/Ido/Query/ServiceStatusQuery.php + + - + message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, mixed given\\.$#" + count: 2 + path: library/Businessprocess/State/IcingaDbState.php + + - + message: "#^Parameter \\#1 \\$array of function array_shift expects array, array\\\\|false given\\.$#" + count: 1 + path: library/Businessprocess/Storage/LegacyConfigParser.php + + - + message: "#^Parameter \\#1 \\$stream of function fclose expects resource, resource\\|false given\\.$#" + count: 1 + path: library/Businessprocess/Storage/LegacyConfigParser.php + + - + message: "#^Parameter \\#1 \\$stream of function fgets expects resource, resource\\|false given\\.$#" + count: 1 + path: library/Businessprocess/Storage/LegacyConfigParser.php + + - + message: "#^Parameter \\#2 \\$values of function vsprintf expects array\\, array\\ given\\.$#" + count: 1 + path: library/Businessprocess/Web/Controller.php + + - + message: "#^Parameter \\#1 \\$array of function array_pop expects array, array\\\\|false given\\.$#" + count: 1 + path: library/Businessprocess/Web/Form/FormLoader.php + + - + message: "#^Parameter \\#1 \\$array of function array_pop expects array, array\\\\|false given\\.$#" + count: 1 + path: library/Businessprocess/Web/Form/QuickForm.php diff --git a/phpstan-baseline-by-php-version.php b/phpstan-baseline-by-php-version.php new file mode 100644 index 00000000..4bd791e8 --- /dev/null +++ b/phpstan-baseline-by-php-version.php @@ -0,0 +1,12 @@ += 80000) { + $includes[] = __DIR__ . '/phpstan-baseline-8x.neon'; +} else { + $includes[] = __DIR__ . '/phpstan-baseline-7x.neon'; +} + +return [ + 'includes' => $includes +]; diff --git a/phpstan-baseline.neon b/phpstan-baseline-standard.neon similarity index 97% rename from phpstan-baseline.neon rename to phpstan-baseline-standard.neon index cd648b95..fa74e35a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline-standard.neon @@ -285,26 +285,6 @@ parameters: count: 1 path: application/controllers/ProcessController.php - - - message: "#^Parameter \\#1 \\$stream of function fpassthru expects resource, resource\\|false given\\.$#" - count: 1 - path: application/controllers/ProcessController.php - - - - message: "#^Parameter \\#1 \\$stream of function fputcsv expects resource, resource\\|false given\\.$#" - count: 2 - path: application/controllers/ProcessController.php - - - - message: "#^Parameter \\#1 \\$stream of function rewind expects resource, resource\\|false given\\.$#" - count: 1 - path: application/controllers/ProcessController.php - - - - message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#" - count: 1 - path: application/controllers/ProcessController.php - - message: "#^Parameter \\#1 \\(mixed\\) of echo cannot be converted to string\\.$#" count: 1 @@ -505,11 +485,6 @@ parameters: count: 1 path: application/forms/AddNodeForm.php - - - message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" - count: 1 - path: application/forms/AddNodeForm.php - - message: "#^Cannot call method getLabel\\(\\) on Zend_Form_Element\\|null\\.$#" count: 1 @@ -1280,11 +1255,6 @@ parameters: count: 1 path: library/Businessprocess/BpConfig.php - - - message: "#^Parameter \\#2 \\$values of function vsprintf expects array\\, array\\ given\\.$#" - count: 2 - path: library/Businessprocess/BpConfig.php - - message: "#^Property Icinga\\\\Module\\\\Businessprocess\\\\BpConfig\\:\\:\\$changeCount has no type specified\\.$#" count: 1 @@ -1555,11 +1525,6 @@ parameters: count: 1 path: library/Businessprocess/BpNode.php - - - message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, array\\\\|null given\\.$#" - count: 1 - path: library/Businessprocess/BpNode.php - - message: "#^Property Icinga\\\\Module\\\\Businessprocess\\\\BpNode\\:\\:\\$childNames type has no value type specified in iterable type array\\.$#" count: 1 @@ -1995,11 +1960,6 @@ parameters: count: 1 path: library/Businessprocess/Modification/NodeAction.php - - - message: "#^Parameter \\#1 \\$string of function ucfirst expects string, mixed given\\.$#" - count: 1 - path: library/Businessprocess/Modification/NodeAction.php - - message: "#^Parameter \\#2 \\$nodeName of static method Icinga\\\\Module\\\\Businessprocess\\\\Modification\\\\NodeAction\\:\\:create\\(\\) expects string, mixed given\\.$#" count: 1 @@ -2055,11 +2015,6 @@ parameters: count: 1 path: library/Businessprocess/Modification/NodeApplyManualOrderAction.php - - - message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" - count: 1 - path: library/Businessprocess/Modification/NodeApplyManualOrderAction.php - - message: "#^Method Icinga\\\\Module\\\\Businessprocess\\\\Modification\\\\NodeCopyAction\\:\\:applyManualSorting\\(\\) has parameter \\$bpNodes with no value type specified in iterable type array\\.$#" count: 1 @@ -2080,11 +2035,6 @@ parameters: count: 1 path: library/Businessprocess/Modification/NodeCopyAction.php - - - message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" - count: 1 - path: library/Businessprocess/Modification/NodeCopyAction.php - - message: "#^Method Icinga\\\\Module\\\\Businessprocess\\\\Modification\\\\NodeCreateAction\\:\\:getProperties\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -2235,11 +2185,6 @@ parameters: count: 1 path: library/Businessprocess/Modification/NodeMoveAction.php - - - message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" - count: 1 - path: library/Businessprocess/Modification/NodeMoveAction.php - - message: "#^Property Icinga\\\\Module\\\\Businessprocess\\\\Modification\\\\NodeMoveAction\\:\\:\\$from \\(int\\) does not accept int\\|false\\.$#" count: 1 @@ -2350,11 +2295,6 @@ parameters: count: 1 path: library/Businessprocess/Monitoring/Backend/Ido/Query/HostStatusQuery.php - - - message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, mixed given\\.$#" - count: 1 - path: library/Businessprocess/Monitoring/Backend/Ido/Query/HostStatusQuery.php - - message: "#^Parameter \\#4 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" count: 1 @@ -2375,11 +2315,6 @@ parameters: count: 1 path: library/Businessprocess/Monitoring/Backend/Ido/Query/ServiceStatusQuery.php - - - message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, mixed given\\.$#" - count: 1 - path: library/Businessprocess/Monitoring/Backend/Ido/Query/ServiceStatusQuery.php - - message: "#^Parameter \\#4 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" count: 1 @@ -2740,21 +2675,11 @@ parameters: count: 1 path: library/Businessprocess/Node.php - - - message: "#^Parameter \\#1 \\$name of static method Icinga\\\\Module\\\\Businessprocess\\\\BpConfig\\:\\:joinNodeName\\(\\) expects string, mixed given\\.$#" - count: 1 - path: library/Businessprocess/ProvidedHook/Icingadb/HostActions.php - - message: "#^Cannot access property \\$name on mixed\\.$#" count: 1 path: library/Businessprocess/ProvidedHook/Icingadb/ServiceActions.php - - - message: "#^Parameter \\#2 \\$suffix of static method Icinga\\\\Module\\\\Businessprocess\\\\BpConfig\\:\\:joinNodeName\\(\\) expects string\\|null, mixed given\\.$#" - count: 1 - path: library/Businessprocess/ProvidedHook/Icingadb/ServiceActions.php - - message: "#^Cannot access offset 'icingacli…' on mixed\\.$#" count: 2 @@ -2915,11 +2840,6 @@ parameters: count: 1 path: library/Businessprocess/Renderer/Renderer.php - - - message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" - count: 1 - path: library/Businessprocess/Renderer/Renderer.php - - message: "#^Property Icinga\\\\Module\\\\Businessprocess\\\\Renderer\\\\Renderer\\:\\:\\$parent \\(Icinga\\\\Module\\\\Businessprocess\\\\BpNode\\) does not accept Icinga\\\\Module\\\\Businessprocess\\\\BpNode\\|null\\.$#" count: 1 @@ -3245,11 +3165,6 @@ parameters: count: 1 path: library/Businessprocess/State/IcingaDbState.php - - - message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, mixed given\\.$#" - count: 2 - path: library/Businessprocess/State/IcingaDbState.php - - message: "#^Method Icinga\\\\Module\\\\Businessprocess\\\\State\\\\MonitoringState\\:\\:apply\\(\\) has no return type specified\\.$#" count: 1 @@ -3530,11 +3445,6 @@ parameters: count: 1 path: library/Businessprocess/Storage/LegacyConfigParser.php - - - message: "#^Parameter \\#1 \\$array of function array_shift expects array, array\\\\|false given\\.$#" - count: 1 - path: library/Businessprocess/Storage/LegacyConfigParser.php - - message: "#^Parameter \\#1 \\$haystack of function strpos expects string, string\\|null given\\.$#" count: 1 @@ -3545,16 +3455,6 @@ parameters: count: 2 path: library/Businessprocess/Storage/LegacyConfigParser.php - - - message: "#^Parameter \\#1 \\$stream of function fclose expects resource, resource\\|false given\\.$#" - count: 1 - path: library/Businessprocess/Storage/LegacyConfigParser.php - - - - message: "#^Parameter \\#1 \\$stream of function fgets expects resource, resource\\|false given\\.$#" - count: 1 - path: library/Businessprocess/Storage/LegacyConfigParser.php - - message: "#^Parameter \\#1 \\$string of function substr expects string, string\\|null given\\.$#" count: 1 @@ -3670,6 +3570,11 @@ parameters: count: 1 path: library/Businessprocess/Storage/LegacyStorage.php + - + message: "#^Method Icinga\\\\Module\\\\Businessprocess\\\\Storage\\\\Storage\\:\\:__construct\\(\\) has parameter \\$config with generic class Icinga\\\\Data\\\\ConfigObject but does not specify its types\\: TValue$#" + count: 1 + path: library/Businessprocess/Storage/Storage.php + - message: "#^Method Icinga\\\\Module\\\\Businessprocess\\\\Storage\\\\Storage\\:\\:deleteProcess\\(\\) has parameter \\$name with no type specified\\.$#" count: 1 @@ -3710,6 +3615,11 @@ parameters: count: 1 path: library/Businessprocess/Storage/Storage.php + - + message: "#^Property Icinga\\\\Module\\\\Businessprocess\\\\Storage\\\\Storage\\:\\:\\$config with generic class Icinga\\\\Data\\\\ConfigObject does not specify its types\\: TValue$#" + count: 1 + path: library/Businessprocess/Storage/Storage.php + - message: "#^Method Icinga\\\\Module\\\\Businessprocess\\\\Web\\\\Component\\\\BpDashboardTile\\:\\:__construct\\(\\) has parameter \\$attributes with no type specified\\.$#" count: 1 @@ -3850,11 +3760,6 @@ parameters: count: 1 path: library/Businessprocess/Web/Controller.php - - - message: "#^Parameter \\#2 \\$values of function vsprintf expects array\\, array\\ given\\.$#" - count: 1 - path: library/Businessprocess/Web/Controller.php - - message: "#^Method Icinga\\\\Module\\\\Businessprocess\\\\Web\\\\FakeRequest\\:\\:getBaseUrl\\(\\) has parameter \\$raw with no type specified\\.$#" count: 1 @@ -3940,11 +3845,6 @@ parameters: count: 1 path: library/Businessprocess/Web/Form/FormLoader.php - - - message: "#^Parameter \\#1 \\$array of function array_pop expects array, array\\\\|false given\\.$#" - count: 1 - path: library/Businessprocess/Web/Form/FormLoader.php - - message: "#^Cannot call method setDecorators\\(\\) on Zend_Form_Element\\|null\\.$#" count: 1 @@ -4390,11 +4290,6 @@ parameters: count: 1 path: library/Businessprocess/Web/Form/QuickForm.php - - - message: "#^Parameter \\#1 \\$array of function array_pop expects array, array\\\\|false given\\.$#" - count: 1 - path: library/Businessprocess/Web/Form/QuickForm.php - - message: "#^Property Icinga\\\\Module\\\\Businessprocess\\\\Web\\\\Form\\\\QuickForm\\:\\:\\$deleteButtonName has no type specified\\.$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index cd7850d9..77094963 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,6 @@ includes: - - phpstan-baseline.neon + - phpstan-baseline-standard.neon + - phpstan-baseline-by-php-version.php parameters: level: max