Skip to content

Commit

Permalink
Merge pull request #226 from Icinga/extend-phpstan
Browse files Browse the repository at this point in the history
Run phpstan for all supported PHP versions
  • Loading branch information
yhabteab authored Nov 17, 2023
2 parents b39b28b + e136833 commit 4db2dd0
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 103 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ 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/icingaweb2-module-director.git vendor/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 https://github.com/Icinga/icingaweb2-module-director.git /usr/share/icingaweb2-modules/director
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
- name: PHP Lint
if: ${{ ! cancelled() }}
Expand All @@ -48,7 +48,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 Down
96 changes: 96 additions & 0 deletions phpstan-baseline-7x.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$x509certdata of function openssl_x509_read expects resource\\|string, mixed given\\.$#"
count: 1
path: application/clicommands/ImportCommand.php

-
message: "#^Parameter \\#1 \\$data of function bin2hex expects string, mixed given\\.$#"
count: 2
path: library/X509/CertificateDetails.php

-
message: "#^Parameter \\#1 \\$x509cert of function openssl_x509_parse expects resource\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateDetails.php

-
message: "#^Parameter \\#2 \\$pieces of function implode expects array, array\\<int, string\\>\\|false given\\.$#"
count: 1
path: library/X509/CertificateDetails.php

-
message: "#^Parameter \\#1 \\$certificate of function openssl_pkey_get_public expects resource\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$key of function openssl_pkey_get_details expects resource, resource\\|false given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$x509 of function openssl_x509_export expects resource\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$x509 of function openssl_x509_fingerprint expects resource\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$x509cert of function openssl_x509_parse expects resource\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#2 \\$str of function explode expects string, string\\|false given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$a of function gmp_add expects GMP\\|int\\|string, GMP\\|null given\\.$#"
count: 1
path: library/X509/Job.php

-
message: "#^Parameter \\#1 \\$a of function gmp_and expects GMP\\|int\\|string, GMP\\|null given\\.$#"
count: 1
path: library/X509/Job.php

-
message: "#^Parameter \\#1 \\$input of function str_pad expects string, string\\|false given\\.$#"
count: 1
path: library/X509/Job.php

-
message: "#^Parameter \\#1 \\$str of function base64_encode expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/DERBase64.php

-
message: "#^Parameter \\#2 \\$str of function explode expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/DERBase64.php

-
message: "#^Parameter \\#1 \\$in_addr of function inet_ntop expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/Ip.php

-
message: "#^Parameter \\#1 \\$input of function str_pad expects string, string\\|false given\\.$#"
count: 1
path: library/X509/Model/Behavior/Ip.php

-
message: "#^Parameter \\#1 \\$ip_address of function inet_pton expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/Ip.php

-
message: "#^Parameter \\#1 \\$str of function ltrim expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/Ip.php
96 changes: 96 additions & 0 deletions phpstan-baseline-8x.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$certificate of function openssl_x509_read expects OpenSSLCertificate\\|string, mixed given\\.$#"
count: 1
path: application/clicommands/ImportCommand.php

-
message: "#^Parameter \\#1 \\$certificate of function openssl_x509_parse expects OpenSSLCertificate\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateDetails.php

-
message: "#^Parameter \\#1 \\$string of function bin2hex expects string, mixed given\\.$#"
count: 2
path: library/X509/CertificateDetails.php

-
message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\<int, string\\>\\|false given\\.$#"
count: 1
path: library/X509/CertificateDetails.php

-
message: "#^Parameter \\#1 \\$certificate of function openssl_x509_export expects OpenSSLCertificate\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$certificate of function openssl_x509_fingerprint expects OpenSSLCertificate\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$certificate of function openssl_x509_parse expects OpenSSLCertificate\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$key of function openssl_pkey_get_details expects OpenSSLAsymmetricKey, OpenSSLAsymmetricKey\\|false given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$public_key of function openssl_pkey_get_public expects array\\|OpenSSLAsymmetricKey\\|OpenSSLCertificate\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#2 \\$string of function explode expects string, string\\|false given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$num1 of function gmp_add expects GMP\\|int\\|string, GMP\\|null given\\.$#"
count: 1
path: library/X509/Job.php

-
message: "#^Parameter \\#1 \\$num1 of function gmp_and expects GMP\\|int\\|string, GMP\\|null given\\.$#"
count: 1
path: library/X509/Job.php

-
message: "#^Parameter \\#1 \\$string of function str_pad expects string, string\\|false given\\.$#"
count: 1
path: library/X509/Job.php

-
message: "#^Parameter \\#1 \\$string of function base64_encode expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/DERBase64.php

-
message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/DERBase64.php

-
message: "#^Parameter \\#1 \\$ip of function inet_ntop expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/Ip.php

-
message: "#^Parameter \\#1 \\$ip of function inet_pton expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/Ip.php

-
message: "#^Parameter \\#1 \\$string of function ltrim expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/Ip.php

-
message: "#^Parameter \\#1 \\$string of function str_pad expects string, string\\|false given\\.$#"
count: 1
path: library/X509/Model/Behavior/Ip.php
10 changes: 10 additions & 0 deletions phpstan-baseline-by-php-version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$includes = [];
if (PHP_VERSION_ID >= 80000) {
$includes[] = __DIR__ . '/phpstan-baseline-8x.neon';
} else {
$includes[] = __DIR__ . '/phpstan-baseline-7x.neon';
}

return ['includes' => $includes];
95 changes: 0 additions & 95 deletions phpstan-baseline.neon → phpstan-baseline-common.neon
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ parameters:
count: 1
path: application/clicommands/ImportCommand.php

-
message: "#^Parameter \\#1 \\$certificate of function openssl_x509_read expects OpenSSLCertificate\\|string, mixed given\\.$#"
count: 1
path: application/clicommands/ImportCommand.php

-
message: "#^Parameter \\#1 \\$file of static method Icinga\\\\Module\\\\X509\\\\CertificateUtils\\:\\:parseBundle\\(\\) expects string, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -375,21 +370,6 @@ parameters:
count: 1
path: library/X509/CertificateDetails.php

-
message: "#^Parameter \\#1 \\$certificate of function openssl_x509_parse expects OpenSSLCertificate\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateDetails.php

-
message: "#^Parameter \\#1 \\$string of function bin2hex expects string, mixed given\\.$#"
count: 2
path: library/X509/CertificateDetails.php

-
message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\<int, string\\>\\|false given\\.$#"
count: 1
path: library/X509/CertificateDetails.php

-
message: "#^Cannot access offset 'bits' on array\\|false\\.$#"
count: 1
Expand Down Expand Up @@ -505,41 +485,16 @@ parameters:
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$certificate of function openssl_x509_export expects OpenSSLCertificate\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$certificate of function openssl_x509_fingerprint expects OpenSSLCertificate\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$certificate of function openssl_x509_parse expects OpenSSLCertificate\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$chainId of closure expects int, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$key of function openssl_pkey_get_details expects OpenSSLAsymmetricKey, OpenSSLAsymmetricKey\\|false given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$orderBy of method ipl\\\\Orm\\\\Query\\:\\:orderBy\\(\\) expects array\\|int\\|string, ipl\\\\Sql\\\\Expression given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#1 \\$public_key of function openssl_pkey_get_public expects array\\|OpenSSLAsymmetricKey\\|OpenSSLCertificate\\|string, mixed given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#2 \\$collection of closure expects array, mixed given\\.$#"
count: 1
Expand All @@ -550,11 +505,6 @@ parameters:
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Parameter \\#2 \\$string of function explode expects string, string\\|false given\\.$#"
count: 1
path: library/X509/CertificateUtils.php

-
message: "#^Method Icinga\\\\Module\\\\X509\\\\CertificatesTable\\:\\:createColumns\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -945,21 +895,6 @@ parameters:
count: 1
path: library/X509/Job.php

-
message: "#^Parameter \\#1 \\$num1 of function gmp_add expects GMP\\|int\\|string, GMP\\|null given\\.$#"
count: 1
path: library/X509/Job.php

-
message: "#^Parameter \\#1 \\$num1 of function gmp_and expects GMP\\|int\\|string, GMP\\|null given\\.$#"
count: 1
path: library/X509/Job.php

-
message: "#^Parameter \\#1 \\$string of function str_pad expects string, string\\|false given\\.$#"
count: 1
path: library/X509/Job.php

-
message: "#^Parameter \\#2 \\$value of static method ipl\\\\Stdlib\\\\Filter\\:\\:equal\\(\\) expects array\\|bool\\|float\\|int\\|string, mixed given\\.$#"
count: 1
Expand All @@ -970,16 +905,6 @@ parameters:
count: 1
path: library/X509/Job.php

-
message: "#^Parameter \\#1 \\$string of function base64_encode expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/DERBase64.php

-
message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/DERBase64.php

-
message: "#^Method Icinga\\\\Module\\\\X509\\\\Model\\\\Behavior\\\\ExpressionInjector\\:\\:__construct\\(\\) has parameter \\$columns with no type specified\\.$#"
count: 1
Expand All @@ -995,26 +920,6 @@ parameters:
count: 1
path: library/X509/Model/Behavior/ExpressionInjector.php

-
message: "#^Parameter \\#1 \\$ip of function inet_ntop expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/Ip.php

-
message: "#^Parameter \\#1 \\$ip of function inet_pton expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/Ip.php

-
message: "#^Parameter \\#1 \\$string of function ltrim expects string, mixed given\\.$#"
count: 1
path: library/X509/Model/Behavior/Ip.php

-
message: "#^Parameter \\#1 \\$string of function str_pad expects string, string\\|false given\\.$#"
count: 1
path: library/X509/Model/Behavior/Ip.php

-
message: "#^Method Icinga\\\\Module\\\\X509\\\\Model\\\\X509Certificate\\:\\:createBehaviors\\(\\) has no return type specified\\.$#"
count: 1
Expand Down
Loading

0 comments on commit 4db2dd0

Please sign in to comment.