Skip to content

Commit

Permalink
phpstan: Streamline vendor file location with local dev-env (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 authored Mar 26, 2024
2 parents 7eaad11 + 087b1b6 commit 4428d78
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 126 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand All @@ -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 }}
Expand All @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion library/Businessprocess/Common/Sort.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public function setSort(?string $sort): self
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':
Expand Down
81 changes: 81 additions & 0 deletions phpstan-baseline-7x.neon
Original file line number Diff line number Diff line change
@@ -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 changes: 81 additions & 0 deletions phpstan-baseline-8x.neon
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions phpstan-baseline-by-php-version.php
Original file line number Diff line number Diff line change
@@ -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
];
Loading

0 comments on commit 4428d78

Please sign in to comment.