Skip to content

Commit 2f675e7

Browse files
php: Split phpstan tests into a separate workflow (#325)
2 parents 5e0d57c + f806671 commit 2f675e7

File tree

7 files changed

+98
-54
lines changed

7 files changed

+98
-54
lines changed

.github/workflows/php.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
20+
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
2121
os: ['ubuntu-latest']
2222

2323
steps:
2424
- name: Checkout code base
25-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
2626

2727
- name: Setup PHP
2828
uses: shivammathur/setup-php@v2
@@ -31,12 +31,7 @@ jobs:
3131
tools: phpcs
3232

3333
- name: Setup dependencies
34-
run: |
35-
composer require -n --no-progress overtrue/phplint
36-
git clone --depth 1 https://github.com/Icinga/icingaweb2.git vendor/icingaweb2
37-
git clone --depth 1 https://github.com/Icinga/icingadb-web.git vendor/icingadb-web
38-
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git vendor/icinga-php-library
39-
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty
34+
run: composer require -n --no-progress overtrue/phplint
4035

4136
- name: PHP Lint
4237
if: ${{ ! cancelled() }}
@@ -45,7 +40,3 @@ jobs:
4540
- name: PHP CodeSniffer
4641
if: ${{ ! cancelled() }}
4742
run: phpcs -wps --colors
48-
49-
- name: PHPStan
50-
if: ${{ ! cancelled() }}
51-
uses: php-actions/phpstan@v3

.github/workflows/phpstan.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: PHPStan
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
phpstan:
10+
uses: icinga/github-actions/.github/workflows/phpstan.yml@main
11+
with:
12+
dependencies: |
13+
{
14+
"/icingaweb2" : "https://github.com/Icinga/icingaweb2.git",
15+
"/usr/share/icingaweb2-modules/icingadb" : "https://github.com/Icinga/icingadb-web.git"
16+
}

phpstan-baseline-7x.neon

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Parameter \\#1 \\$str of function urldecode expects string, mixed given\\.$#"
5+
count: 1
6+
path: application/controllers/HostsController.php
7+
8+
-
9+
message: "#^Parameter \\#1 \\$str of function urldecode expects string, mixed given\\.$#"
10+
count: 1
11+
path: application/controllers/ServicesController.php
12+
13+
-
14+
message: "#^Argument of an invalid type array\\<int, string\\>\\|false supplied for foreach, only iterables are supported\\.$#"
15+
count: 1
16+
path: library/Graphite/Util/MacroTemplate.php
17+
18+
-
19+
message: "#^Cannot access offset int on non\\-empty\\-array\\<int, string\\>\\|false\\.$#"
20+
count: 1
21+
path: library/Graphite/Util/MacroTemplate.php
22+
23+
-
24+
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, array\\<int, string\\>\\|false given\\.$#"
25+
count: 1
26+
path: library/Graphite/Util/MacroTemplate.php
27+
28+
-
29+
message: "#^Property Icinga\\\\Module\\\\Graphite\\\\Util\\\\MacroTemplate\\:\\:\\$template \\(array\\<string\\>\\) does not accept array\\<int, string\\>\\|false\\.$#"
30+
count: 1
31+
path: library/Graphite/Util/MacroTemplate.php
32+
33+
-
34+
message: "#^Parameter \\#1 \\$str of function strtolower expects string, mixed given\\.$#"
35+
count: 1
36+
path: library/Graphite/Web/Controller/MonitoringAwareController.php

phpstan-baseline-8x.neon

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Parameter \\#1 \\$string of function urldecode expects string, mixed given\\.$#"
5+
count: 1
6+
path: application/controllers/HostsController.php
7+
8+
-
9+
message: "#^Parameter \\#1 \\$string of function urldecode expects string, mixed given\\.$#"
10+
count: 1
11+
path: application/controllers/ServicesController.php
12+
13+
-
14+
message: "#^Parameter \\#1 \\$separator of function explode expects non\\-empty\\-string, string given\\.$#"
15+
count: 1
16+
path: library/Graphite/Util/MacroTemplate.php
17+
18+
-
19+
message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#"
20+
count: 1
21+
path: library/Graphite/Web/Controller/MonitoringAwareController.php
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
$includes = [];
4+
if (PHP_VERSION_ID < 80000) {
5+
$includes[] = __DIR__ . '/phpstan-baseline-7x.neon';
6+
} else {
7+
$includes[] = __DIR__ . '/phpstan-baseline-8x.neon';
8+
}
9+
10+
return [
11+
'includes' => $includes
12+
];
Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ parameters:
4545
count: 1
4646
path: application/controllers/GraphController.php
4747

48-
-
49-
message: "#^Parameter \\#2 \\$checkCommand of method Icinga\\\\Module\\\\Graphite\\\\Controllers\\\\GraphController\\:\\:supplyImage\\(\\) expects string, mixed given\\.$#"
50-
count: 2
51-
path: application/controllers/GraphController.php
52-
5348
-
5449
message: "#^Parameter \\#2 \\$value of static method ipl\\\\Stdlib\\\\Filter\\:\\:equal\\(\\) expects array\\|bool\\|float\\|int\\|string, mixed given\\.$#"
5550
count: 3
@@ -85,11 +80,6 @@ parameters:
8580
count: 1
8681
path: application/controllers/HostsController.php
8782

88-
-
89-
message: "#^Parameter \\#1 \\$string of function urldecode expects string, mixed given\\.$#"
90-
count: 1
91-
path: application/controllers/HostsController.php
92-
9383
-
9484
message: "#^Parameter \\#2 \\$value of static method ipl\\\\Stdlib\\\\Filter\\:\\:equal\\(\\) expects array\\|bool\\|float\\|int\\|string, mixed given\\.$#"
9585
count: 1
@@ -190,11 +180,6 @@ parameters:
190180
count: 1
191181
path: application/controllers/ServicesController.php
192182

193-
-
194-
message: "#^Parameter \\#1 \\$string of function urldecode expects string, mixed given\\.$#"
195-
count: 1
196-
path: application/controllers/ServicesController.php
197-
198183
-
199184
message: "#^Parameter \\#2 \\$value of static method ipl\\\\Stdlib\\\\Filter\\:\\:equal\\(\\) expects array\\|bool\\|float\\|int\\|string, mixed given\\.$#"
200185
count: 1
@@ -385,6 +370,11 @@ parameters:
385370
count: 1
386371
path: library/Graphite/Graphing/MetricsQuery.php
387372

373+
-
374+
message: "#^Parameter \\#2 \\$object of method Icinga\\\\Module\\\\Graphite\\\\Util\\\\IcingadbUtils\\:\\:resolveMacro\\(\\) expects Icinga\\\\Module\\\\Icingadb\\\\Compat\\\\CompatHost\\|Icinga\\\\Module\\\\Icingadb\\\\Compat\\\\CompatService\\|Icinga\\\\Module\\\\Icingadb\\\\Model\\\\Host\\|Icinga\\\\Module\\\\Icingadb\\\\Model\\\\Service, ipl\\\\Orm\\\\Model given\\.$#"
375+
count: 1
376+
path: library/Graphite/Graphing/MetricsQuery.php
377+
388378
-
389379
message: "#^Call to an undefined method Icinga\\\\Data\\\\Fetchable\\:\\:where\\(\\)\\.$#"
390380
count: 1
@@ -515,11 +505,6 @@ parameters:
515505
count: 1
516506
path: library/Graphite/Util/InternalProcessTracker.php
517507

518-
-
519-
message: "#^Parameter \\#1 \\$separator of function explode expects non\\-empty\\-string, string given\\.$#"
520-
count: 1
521-
path: library/Graphite/Util/MacroTemplate.php
522-
523508
-
524509
message: "#^Cannot cast mixed to int\\.$#"
525510
count: 2
@@ -560,11 +545,6 @@ parameters:
560545
count: 1
561546
path: library/Graphite/Web/Controller/MonitoringAwareController.php
562547

563-
-
564-
message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#"
565-
count: 1
566-
path: library/Graphite/Web/Controller/MonitoringAwareController.php
567-
568548
-
569549
message: "#^Parameter \\#1 \\$value of method Icinga\\\\Module\\\\Graphite\\\\Web\\\\Form\\\\Validator\\\\CustomErrorMessagesValidator\\:\\:validate\\(\\) expects string, mixed given\\.$#"
570550
count: 1
@@ -705,21 +685,11 @@ parameters:
705685
count: 1
706686
path: library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbHost.php
707687

708-
-
709-
message: "#^Method Icinga\\\\Module\\\\Graphite\\\\Web\\\\Widget\\\\Graphs\\\\Icingadb\\\\IcingadbHost\\:\\:getMonitoredObjectIdentifier\\(\\) should return string but returns mixed\\.$#"
710-
count: 1
711-
path: library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbHost.php
712-
713688
-
714689
message: "#^Method Icinga\\\\Module\\\\Graphite\\\\Web\\\\Widget\\\\Graphs\\\\Icingadb\\\\IcingadbHost\\:\\:getObjectType\\(\\) has no return type specified\\.$#"
715690
count: 1
716691
path: library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbHost.php
717692

718-
-
719-
message: "#^Parameter \\#2 \\$value of method Icinga\\\\Web\\\\Url\\:\\:setParam\\(\\) expects array\\|bool\\|string, mixed given\\.$#"
720-
count: 1
721-
path: library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbHost.php
722-
723693
-
724694
message: "#^Cannot access property \\$name on mixed\\.$#"
725695
count: 4
@@ -745,11 +715,6 @@ parameters:
745715
count: 1
746716
path: library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbService.php
747717

748-
-
749-
message: "#^Parameter \\#2 \\$value of method Icinga\\\\Web\\\\Url\\:\\:setParam\\(\\) expects array\\|bool\\|string, mixed given\\.$#"
750-
count: 1
751-
path: library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbService.php
752-
753718
-
754719
message: "#^Call to an undefined method Icinga\\\\Module\\\\Graphite\\\\Web\\\\Widget\\\\Graphs\\\\Icingadb\\\\IcingadbHost\\|Icinga\\\\Module\\\\Graphite\\\\Web\\\\Widget\\\\Graphs\\\\Icingadb\\\\IcingadbService\\:\\:createServiceTitle\\(\\)\\.$#"
755720
count: 1

phpstan.neon

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
includes:
2-
- phpstan-baseline.neon
2+
- phpstan-baseline-standard.neon
3+
- phpstan-baseline-by-php-version.php
34

45
parameters:
56
level: max
@@ -13,7 +14,9 @@ parameters:
1314
- library
1415

1516
scanDirectories:
16-
- vendor
17+
- /icingaweb2
18+
- /usr/share/icinga-php
19+
- /usr/share/icingaweb2-modules
1720

1821
ignoreErrors:
1922
-

0 commit comments

Comments
 (0)