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

phpstan: Streamline vendor file location with local dev-env #130

Merged
merged 2 commits into from
Feb 13, 2024
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
14 changes: 7 additions & 7 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 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() }}
Expand All @@ -49,4 +49,4 @@ jobs:

- name: PHPStan
if: ${{ ! cancelled() }}
uses: php-actions/phpstan@v3
run: ./vendor/bin/phpstan analyse
71 changes: 71 additions & 0 deletions phpstan-baseline-7x.neon
Original file line number Diff line number Diff line change
@@ -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\\<int\\|string\\>, 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\\<bool\\|float\\|int\\|string\\|null\\>, array\\<int, mixed\\> 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
66 changes: 66 additions & 0 deletions phpstan-baseline-8x.neon
Original file line number Diff line number Diff line change
@@ -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\\<int\\|string\\>, 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\\<bool\\|float\\|int\\|string\\|null\\>, array\\<int\\|string, mixed\\> 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
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
];
65 changes: 0 additions & 65 deletions phpstan-baseline.neon → phpstan-baseline-standard.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1170,31 +1165,6 @@ parameters:
count: 1
path: library/Jira/RestApi.php

-
message: "#^Parameter \\#1 \\$array of function array_flip expects array\\<int\\|string\\>, 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
Expand All @@ -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\\<string, array\\<int, mixed\\>\\|int\\|string\\> given\\.$#"
count: 2
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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\\<bool\\|float\\|int\\|string\\|null\\>, array\\<int\\|string, mixed\\> given\\.$#"
count: 1
path: library/Jira/Web/Controller.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
Expand Down Expand Up @@ -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\\<min, \\-1\\>\\|int\\<1, max\\>\\|string given\\.$#"
count: 1
Expand Down
7 changes: 5 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
includes:
- phpstan-baseline.neon
- phpstan-baseline-standard.neon
- phpstan-baseline-by-php-version.php

parameters:
level: max
Expand All @@ -13,7 +14,9 @@ parameters:
- library

scanDirectories:
- vendor
- /icingaweb2
- /usr/share/icinga-php
- /usr/share/icingaweb2-modules

ignoreErrors:
-
Expand Down
Loading