Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run phpstan for all supported PHP versions #226

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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