From 66015c2ef577ba57c23107ddad4485a02764d4c6 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 25 Mar 2024 11:28:14 +0100 Subject: [PATCH 1/4] phpstan: Streamline vendor file location with local dev-env phpstan is not run with an action anymore, as the action runs it its own docker container and hence has no access to files outside the repository root. A side-effect of this is, that phpstan now **really** runs with the php version set up by the matrix. --- .github/workflows/php.yml | 13 +++++++------ phpstan.neon | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 87bdafb..9e4183e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -32,11 +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/modules/icingadb-web - 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 -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 + 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 + - name: PHP Lint if: ${{ ! cancelled() }} @@ -48,4 +49,4 @@ jobs: - name: PHPStan if: ${{ ! cancelled() }} - uses: php-actions/phpstan@v3 + run: ./vendor/bin/phpstan analyse diff --git a/phpstan.neon b/phpstan.neon index 82abfa0..d400f2c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -13,7 +13,9 @@ parameters: - library scanDirectories: - - vendor + - /icingaweb2 + - /usr/share/icinga-php + - /usr/share/icingaweb2-modules ignoreErrors: - From 8602202ecc01209e079c4b5645a0cf6d17658a0d Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 25 Mar 2024 11:30:51 +0100 Subject: [PATCH 2/4] Github Actions: Add php 8.3 --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 9e4183e..7493428 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] os: ['ubuntu-latest'] steps: From 9b0f1d8cf2e84462ebbf666caabb7f28c57d2448 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 25 Mar 2024 12:32:04 +0100 Subject: [PATCH 3/4] Update phpstan baseline --- phpstan-baseline.neon | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0c37e72..99bd797 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -860,11 +860,6 @@ parameters: count: 1 path: library/Cube/Ido/IdoCube.php - - - message: "#^Cannot access offset 'host'\\|'service' on array\\|stdClass\\.$#" - count: 1 - path: library/Cube/Ido/IdoCube.php - - message: "#^Cannot call method getDbAdapter\\(\\) on mixed\\.$#" count: 1 From da34bb164d938678c0872d895d8de63633990e11 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 25 Mar 2024 12:58:12 +0100 Subject: [PATCH 4/4] phpstan: Separate baseline by php version --- phpstan-baseline-7x.neon | 16 ++++++++++++++++ phpstan-baseline-8x.neon | 6 ++++++ phpstan-baseline-by-php-version.php | 12 ++++++++++++ ...seline.neon => phpstan-baseline-standard.neon | 5 ----- phpstan.neon | 3 ++- 5 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 phpstan-baseline-7x.neon create mode 100644 phpstan-baseline-8x.neon create mode 100644 phpstan-baseline-by-php-version.php rename phpstan-baseline.neon => phpstan-baseline-standard.neon (99%) diff --git a/phpstan-baseline-7x.neon b/phpstan-baseline-7x.neon new file mode 100644 index 0000000..6e4c763 --- /dev/null +++ b/phpstan-baseline-7x.neon @@ -0,0 +1,16 @@ +parameters: + ignoreErrors: + - + message: "#^Method Icinga\\\\Module\\\\Cube\\\\Ido\\\\IdoHostStatusCube\\:\\:listAvailableDimensions\\(\\) should return array but returns array\\\\|false\\.$#" + count: 1 + path: library/Cube/Ido/IdoHostStatusCube.php + + - + message: "#^Method Icinga\\\\Module\\\\Cube\\\\Ido\\\\IdoServiceStatusCube\\:\\:listAvailableDimensions\\(\\) should return array but returns array\\\\|false\\.$#" + count: 1 + path: library/Cube/Ido/IdoServiceStatusCube.php + + - + message: "#^Parameter \\#1 \\$function of function call_user_func_array expects callable\\(\\)\\: mixed, array\\{Zend_Db_Select, string\\} given\\.$#" + count: 1 + path: library/Cube/Ido/ZfSelectWrapper.php diff --git a/phpstan-baseline-8x.neon b/phpstan-baseline-8x.neon new file mode 100644 index 0000000..7ea3ac5 --- /dev/null +++ b/phpstan-baseline-8x.neon @@ -0,0 +1,6 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\#1 \\$callback of function call_user_func_array expects callable\\(\\)\\: mixed, array\\{Zend_Db_Select, string\\} given\\.$#" + count: 1 + path: library/Cube/Ido/ZfSelectWrapper.php diff --git a/phpstan-baseline-by-php-version.php b/phpstan-baseline-by-php-version.php new file mode 100644 index 0000000..05107df --- /dev/null +++ b/phpstan-baseline-by-php-version.php @@ -0,0 +1,12 @@ + $includes +]; diff --git a/phpstan-baseline.neon b/phpstan-baseline-standard.neon similarity index 99% rename from phpstan-baseline.neon rename to phpstan-baseline-standard.neon index 99bd797..6a78bcf 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline-standard.neon @@ -985,11 +985,6 @@ parameters: count: 1 path: library/Cube/Ido/ZfSelectWrapper.php - - - message: "#^Parameter \\#1 \\$callback of function call_user_func_array expects callable\\(\\)\\: mixed, array\\{Zend_Db_Select, string\\} given\\.$#" - count: 1 - path: library/Cube/Ido/ZfSelectWrapper.php - - message: "#^Parameter \\#1 \\$rule of method ipl\\\\Stdlib\\\\Filter\\\\Chain\\:\\:add\\(\\) expects ipl\\\\Stdlib\\\\Filter\\\\Rule, ipl\\\\Stdlib\\\\Filter\\\\Rule\\|null given\\.$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index d400f2c..27fce80 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