phpstan: Streamline vendor file location with local dev-env (#442)

This commit is contained in:
Sukhwinder Dhillon 2024-03-26 15:55:47 +01:00 committed by GitHub
commit 4428d78da9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 200 additions and 126 deletions

View file

@ -32,12 +32,12 @@ jobs:
- name: Setup dependencies
run: |
composer require -n --no-progress overtrue/phplint
git clone --depth 1 https://github.com/Icinga/icingaweb2.git vendor/icingaweb2
git clone --depth 1 https://github.com/Icinga/icingadb-web.git vendor/icingadb-web
git clone --depth 1 https://github.com/Icinga/icingaweb2-module-director.git vendor/icingaweb2-module-director
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git vendor/icinga-php-library
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty
composer require -n --no-progress overtrue/phplint phpstan/phpstan
sudo git clone --depth 1 https://github.com/Icinga/icingaweb2.git /icingaweb2
sudo git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git /usr/share/icinga-php/ipl
sudo git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git /usr/share/icinga-php/vendor
sudo git clone --depth 1 https://github.com/Icinga/icingadb-web.git /usr/share/icingaweb2-modules/icingadb-web
sudo git clone --depth 1 https://github.com/Icinga/icingaweb2-module-director.git /usr/share/icingaweb2-modules/icingaweb2-module-director
- name: PHP Lint
if: ${{ ! cancelled() }}
@ -49,7 +49,7 @@ jobs:
- name: PHPStan
if: ${{ ! cancelled() }}
uses: php-actions/phpstan@v3
run: ./vendor/bin/phpstan analyse
test:
name: Unit tests with php ${{ matrix.php }} on ${{ matrix.os }}
@ -61,7 +61,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
os: ['ubuntu-latest']
steps:

View file

@ -41,7 +41,9 @@ trait Sort
return $this;
}
list($sortBy, $direction) = Str::symmetricSplit($sort, ' ', 2, 'asc');
/** @var array<int, string> $res */
$res = Str::symmetricSplit($sort, ' ', 2, 'asc');
[$sortBy, $direction] = $res;
switch ($sortBy) {
case 'manual':

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

@ -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\\<bool\\|float\\|int\\|string\\|null\\>, array\\<int, mixed\\> given\\.$#"
count: 2
path: library/Businessprocess/BpConfig.php
-
message: "#^Parameter \\#2 \\$search of function array_key_exists expects array, array\\<Icinga\\\\Module\\\\Businessprocess\\\\Node\\>\\|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\\<int, string\\>\\|false given\\.$#"
count: 1
path: library/Businessprocess/Storage/LegacyConfigParser.php
-
message: "#^Parameter \\#2 \\$args of function vsprintf expects array\\<bool\\|float\\|int\\|string\\|null\\>, array\\<int, mixed\\> given\\.$#"
count: 1
path: library/Businessprocess/Web/Controller.php
-
message: "#^Parameter \\#1 \\$stack of function array_pop expects array, array\\<int, string\\>\\|false given\\.$#"
count: 1
path: library/Businessprocess/Web/Form/FormLoader.php
-
message: "#^Parameter \\#1 \\$stack of function array_pop expects array, array\\<int, string\\>\\|false given\\.$#"
count: 1
path: library/Businessprocess/Web/Form/QuickForm.php

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

@ -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\\<bool\\|float\\|int\\|string\\|null\\>, array\\<int, mixed\\> given\\.$#"
count: 2
path: library/Businessprocess/BpConfig.php
-
message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, array\\<Icinga\\\\Module\\\\Businessprocess\\\\Node\\>\\|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\\<int, string\\>\\|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\\<bool\\|float\\|int\\|string\\|null\\>, array\\<int, mixed\\> given\\.$#"
count: 1
path: library/Businessprocess/Web/Controller.php
-
message: "#^Parameter \\#1 \\$array of function array_pop expects array, array\\<int, string\\>\\|false given\\.$#"
count: 1
path: library/Businessprocess/Web/Form/FormLoader.php
-
message: "#^Parameter \\#1 \\$array of function array_pop expects array, array\\<int, string\\>\\|false given\\.$#"
count: 1
path: library/Businessprocess/Web/Form/QuickForm.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

@ -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\\<bool\\|float\\|int\\|string\\|null\\>, array\\<int, mixed\\> 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\\<Icinga\\\\Module\\\\Businessprocess\\\\Node\\>\\|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\\<int, string\\>\\|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\\<bool\\|float\\|int\\|string\\|null\\>, array\\<int, mixed\\> 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\\<int, string\\>\\|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\\<int, string\\>\\|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

View file

@ -1,5 +1,6 @@
includes:
- phpstan-baseline.neon
- phpstan-baseline-standard.neon
- phpstan-baseline-by-php-version.php
parameters:
level: max
@ -13,7 +14,9 @@ parameters:
- library
scanDirectories:
- vendor
- /icingaweb2
- /usr/share/icinga-php
- /usr/share/icingaweb2-modules
excludePaths:
- library/Businessprocess/Test