diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index e238677..a3a870e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -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 https://github.com/Icinga/icingadb-web.git /usr/share/icingaweb2-modules/icingadb + 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() }} @@ -49,4 +49,4 @@ jobs: - name: PHPStan if: ${{ ! cancelled() }} - uses: php-actions/phpstan@v3 + run: ./vendor/bin/phpstan analyse diff --git a/phpstan-baseline-7x.neon b/phpstan-baseline-7x.neon new file mode 100644 index 0000000..7db1d84 --- /dev/null +++ b/phpstan-baseline-7x.neon @@ -0,0 +1,71 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\#1 \\$str of function rtrim expects string, mixed given\\.$#" + count: 1 + path: library/Jira/LinkHelper.php + + - + message: "#^Method Icinga\\\\Module\\\\Jira\\\\RestApi\\:\\:curl\\(\\) has invalid return type CurlHandle\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#1 \\$ch of function curl_error expects resource, CurlHandle\\|resource given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#1 \\$ch of function curl_exec expects resource, CurlHandle\\|resource given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#1 \\$ch of function curl_getinfo expects resource, CurlHandle\\|resource given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#1 \\$ch of function curl_setopt_array expects resource, CurlHandle\\|resource given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#1 \\$input of function array_flip expects array\\, array\\|null given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#2 \\$search of function array_key_exists expects array, array\\|null given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#2 \\$str of function explode expects string, mixed given\\.$#" + count: 1 + path: library/Jira/Validator/PhpSessionBasedCsrfTokenValidator.php + + - + message: "#^Parameter \\#1 \\$function of function call_user_func expects callable\\(\\)\\: mixed, array given\\.$#" + count: 1 + path: library/Jira/Web/Controller.php + + - + message: "#^Parameter \\#1 \\$function of function call_user_func expects callable\\(\\)\\: mixed, array\\{\\$this\\(Icinga\\\\Module\\\\Jira\\\\Web\\\\Controller\\), string\\} given\\.$#" + count: 1 + path: library/Jira/Web/Controller.php + + - + message: "#^Parameter \\#2 \\$args of function vsprintf expects array\\, array\\ given\\.$#" + count: 1 + path: library/Jira/Web/Controller.php + + - + message: "#^Parameter \\#1 \\$str of function rawurlencode expects string, mixed given\\.$#" + count: 2 + path: library/Jira/Web/Form/NewIssueForm.php diff --git a/phpstan-baseline-8x.neon b/phpstan-baseline-8x.neon new file mode 100644 index 0000000..e66bab8 --- /dev/null +++ b/phpstan-baseline-8x.neon @@ -0,0 +1,66 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\#1 \\$string of function rtrim expects string, mixed given\\.$#" + count: 1 + path: library/Jira/LinkHelper.php + + - + message: "#^Parameter \\#1 \\$array of function array_flip expects array\\, array\\|null given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#1 \\$handle of function curl_error expects CurlHandle, CurlHandle\\|resource given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#1 \\$handle of function curl_exec expects CurlHandle, CurlHandle\\|resource given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#1 \\$handle of function curl_getinfo expects CurlHandle, CurlHandle\\|resource given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#1 \\$handle of function curl_setopt_array expects CurlHandle, CurlHandle\\|resource given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#1 \\$string of function trim expects string, mixed given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, array\\|null given\\.$#" + count: 1 + path: library/Jira/RestApi.php + + - + message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#" + count: 1 + path: library/Jira/Validator/PhpSessionBasedCsrfTokenValidator.php + + - + message: "#^Parameter \\#1 \\$callback of function call_user_func expects callable\\(\\)\\: mixed, array given\\.$#" + count: 1 + path: library/Jira/Web/Controller.php + + - + message: "#^Parameter \\#1 \\$callback of function call_user_func expects callable\\(\\)\\: mixed, array\\{\\$this\\(Icinga\\\\Module\\\\Jira\\\\Web\\\\Controller\\), string\\} given\\.$#" + count: 1 + path: library/Jira/Web/Controller.php + + - + message: "#^Parameter \\#2 \\$values of function vsprintf expects array\\, array\\ given\\.$#" + count: 1 + path: library/Jira/Web/Controller.php + + - + message: "#^Parameter \\#1 \\$string of function rawurlencode expects string, mixed given\\.$#" + count: 2 + path: library/Jira/Web/Form/NewIssueForm.php diff --git a/phpstan-baseline-by-php-version.php b/phpstan-baseline-by-php-version.php new file mode 100644 index 0000000..4bd791e --- /dev/null +++ b/phpstan-baseline-by-php-version.php @@ -0,0 +1,12 @@ += 80000) { + $includes[] = __DIR__ . '/phpstan-baseline-8x.neon'; +} else { + $includes[] = __DIR__ . '/phpstan-baseline-7x.neon'; +} + +return [ + 'includes' => $includes +]; diff --git a/phpstan-baseline.neon b/phpstan-baseline-standard.neon similarity index 97% rename from phpstan-baseline.neon rename to phpstan-baseline-standard.neon index 98e6ba2..431da3c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline-standard.neon @@ -795,11 +795,6 @@ parameters: count: 1 path: library/Jira/LinkHelper.php - - - message: "#^Parameter \\#1 \\$string of function rtrim expects string, mixed given\\.$#" - count: 1 - path: library/Jira/LinkHelper.php - - message: "#^Property Icinga\\\\Module\\\\Jira\\\\LinkHelper\\:\\:\\$icingaUrl has no type specified\\.$#" count: 1 @@ -1170,31 +1165,6 @@ parameters: count: 1 path: library/Jira/RestApi.php - - - message: "#^Parameter \\#1 \\$array of function array_flip expects array\\, array\\|null given\\.$#" - count: 1 - path: library/Jira/RestApi.php - - - - message: "#^Parameter \\#1 \\$handle of function curl_error expects CurlHandle, CurlHandle\\|resource given\\.$#" - count: 1 - path: library/Jira/RestApi.php - - - - message: "#^Parameter \\#1 \\$handle of function curl_exec expects CurlHandle, CurlHandle\\|resource given\\.$#" - count: 1 - path: library/Jira/RestApi.php - - - - message: "#^Parameter \\#1 \\$handle of function curl_getinfo expects CurlHandle, CurlHandle\\|resource given\\.$#" - count: 1 - path: library/Jira/RestApi.php - - - - message: "#^Parameter \\#1 \\$handle of function curl_setopt_array expects CurlHandle, CurlHandle\\|resource given\\.$#" - count: 1 - path: library/Jira/RestApi.php - - message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|true given\\.$#" count: 1 @@ -1210,16 +1180,6 @@ parameters: count: 1 path: library/Jira/RestApi.php - - - message: "#^Parameter \\#1 \\$string of function trim expects string, mixed given\\.$#" - count: 1 - path: library/Jira/RestApi.php - - - - message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, array\\|null given\\.$#" - count: 1 - path: library/Jira/RestApi.php - - message: "#^Parameter \\#2 \\$body of method Icinga\\\\Module\\\\Jira\\\\RestApi\\:\\:post\\(\\) expects null, array\\\\|int\\|string\\> given\\.$#" count: 2 @@ -1365,11 +1325,6 @@ parameters: count: 1 path: library/Jira/Validator/PhpSessionBasedCsrfTokenValidator.php - - - message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#" - count: 1 - path: library/Jira/Validator/PhpSessionBasedCsrfTokenValidator.php - - message: "#^Method Icinga\\\\Module\\\\Jira\\\\Validator\\\\SimpleValidator\\:\\:__construct\\(\\) has parameter \\$settings with no value type specified in iterable type array\\.$#" count: 1 @@ -1425,21 +1380,6 @@ parameters: count: 1 path: library/Jira/Web/Controller.php - - - message: "#^Parameter \\#1 \\$callback of function call_user_func expects callable\\(\\)\\: mixed, array given\\.$#" - count: 1 - path: library/Jira/Web/Controller.php - - - - message: "#^Parameter \\#1 \\$callback of function call_user_func expects callable\\(\\)\\: mixed, array\\{\\$this\\(Icinga\\\\Module\\\\Jira\\\\Web\\\\Controller\\), string\\} given\\.$#" - count: 1 - path: library/Jira/Web/Controller.php - - - - message: "#^Parameter \\#2 \\$values of function vsprintf expects array\\, array\\ given\\.$#" - count: 1 - path: library/Jira/Web/Controller.php - - message: "#^Cannot cast mixed to int\\.$#" count: 1 @@ -1565,11 +1505,6 @@ parameters: count: 1 path: library/Jira/Web/Form/NewIssueForm.php - - - message: "#^Parameter \\#1 \\$string of function rawurlencode expects string, mixed given\\.$#" - count: 2 - path: library/Jira/Web/Form/NewIssueForm.php - - message: "#^Parameter \\#2 \\$name of method ipl\\\\Html\\\\Form\\:\\:addElement\\(\\) expects string\\|null, int\\\\|int\\<1, max\\>\\|string given\\.$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index 55860ec..b5f0eb9 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -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 ignoreErrors: -