From 9a337a7e554b73d1a21b8631e0ba8e6a26a3bb40 Mon Sep 17 00:00:00 2001 From: raviks789 <33730024+raviks789@users.noreply.github.com> Date: Wed, 23 Aug 2023 14:50:20 +0200 Subject: [PATCH 1/3] Add PHP 8.2 to the workflow --- .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 fef9e7d..f523128 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'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] os: ['ubuntu-latest'] steps: From c59c8e1967e12fbf2757aa1680d1e2b54da9716b Mon Sep 17 00:00:00 2001 From: raviks789 <33730024+raviks789@users.noreply.github.com> Date: Wed, 23 Aug 2023 14:30:25 +0200 Subject: [PATCH 2/3] Add PHPStan static analyser to the workflow Also dependencies required for PHPStan in the workflow is updated. --- .github/workflows/php.yml | 10 +++- phpstan-baseline.neon | 96 +++++++++++++++++++++++++++++++++++++++ phpstan.neon | 26 +++++++++++ 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index f523128..ec14747 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -31,7 +31,11 @@ jobs: tools: phpcs - name: Setup dependencies - run: composer require -n --no-progress overtrue/phplint + run: | + composer require -n --no-progress overtrue/phplint ipl/i18n:@dev + 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 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty - name: PHP Lint if: success() || matrix.allow_failure @@ -40,3 +44,7 @@ jobs: - name: PHP CodeSniffer if: success() || matrix.allow_failure run: phpcs + + - name: PHPStan + uses: php-actions/phpstan@v3 + if: success() || matrix.allow_failure diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..3acf2b3 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,96 @@ +parameters: + ignoreErrors: + - + message: "#^Method Icinga\\\\Module\\\\Generictts\\\\Controllers\\\\IntegrationsController\\:\\:indexAction\\(\\) has no return type specified\\.$#" + count: 1 + path: application/controllers/IntegrationsController.php + + - + message: "#^Method Icinga\\\\Module\\\\Generictts\\\\Controllers\\\\IntegrationsController\\:\\:newAction\\(\\) has no return type specified\\.$#" + count: 1 + path: application/controllers/IntegrationsController.php + + - + message: "#^Method Icinga\\\\Module\\\\Generictts\\\\Controllers\\\\IntegrationsController\\:\\:removeAction\\(\\) has no return type specified\\.$#" + count: 1 + path: application/controllers/IntegrationsController.php + + - + message: "#^Method Icinga\\\\Module\\\\Generictts\\\\Controllers\\\\IntegrationsController\\:\\:updateAction\\(\\) has no return type specified\\.$#" + count: 1 + path: application/controllers/IntegrationsController.php + + - + message: "#^Parameter \\#1 \\$name of method Icinga\\\\Module\\\\Generictts\\\\Forms\\\\Config\\\\TtsIntegrationConfigForm\\:\\:bind\\(\\) expects string, mixed given\\.$#" + count: 2 + path: application/controllers/IntegrationsController.php + + - + message: "#^Parameter \\#1 \\$name of method Icinga\\\\Module\\\\Generictts\\\\Forms\\\\Config\\\\TtsIntegrationConfigForm\\:\\:remove\\(\\) expects string, mixed given\\.$#" + count: 1 + path: application/controllers/IntegrationsController.php + + - + message: "#^Cannot call method getValue\\(\\) on Zend_Form_Element\\|null\\.$#" + count: 3 + path: application/forms/Config/TtsIntegrationConfigForm.php + + - + message: "#^Method Icinga\\\\Module\\\\Generictts\\\\Forms\\\\Config\\\\TtsIntegrationConfigForm\\:\\:add\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#" + count: 1 + path: application/forms/Config/TtsIntegrationConfigForm.php + + - + message: "#^Method Icinga\\\\Module\\\\Generictts\\\\Forms\\\\Config\\\\TtsIntegrationConfigForm\\:\\:createElements\\(\\) has no return type specified\\.$#" + count: 1 + path: application/forms/Config/TtsIntegrationConfigForm.php + + - + message: "#^Method Icinga\\\\Module\\\\Generictts\\\\Forms\\\\Config\\\\TtsIntegrationConfigForm\\:\\:createElements\\(\\) has parameter \\$formData with no value type specified in iterable type array\\.$#" + count: 1 + path: application/forms/Config/TtsIntegrationConfigForm.php + + - + message: "#^Method Icinga\\\\Module\\\\Generictts\\\\Forms\\\\Config\\\\TtsIntegrationConfigForm\\:\\:onRequest\\(\\) has no return type specified\\.$#" + count: 1 + path: application/forms/Config/TtsIntegrationConfigForm.php + + - + message: "#^Method Icinga\\\\Module\\\\Generictts\\\\Forms\\\\Config\\\\TtsIntegrationConfigForm\\:\\:update\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#" + count: 1 + path: application/forms/Config/TtsIntegrationConfigForm.php + + - + message: "#^Parameter \\#1 \\$name of method Icinga\\\\Module\\\\Generictts\\\\Forms\\\\Config\\\\TtsIntegrationConfigForm\\:\\:add\\(\\) expects string, mixed given\\.$#" + count: 1 + path: application/forms/Config/TtsIntegrationConfigForm.php + + - + message: "#^Parameter \\#1 \\$name of method Icinga\\\\Module\\\\Generictts\\\\Forms\\\\Config\\\\TtsIntegrationConfigForm\\:\\:update\\(\\) expects string, mixed given\\.$#" + count: 1 + path: application/forms/Config/TtsIntegrationConfigForm.php + + - + message: "#^Method Icinga\\\\Module\\\\Generictts\\\\Ticket\\:\\:createLink\\(\\) has parameter \\$match with no value type specified in iterable type array\\.$#" + count: 1 + path: library/Generictts/Ticket.php + + - + message: "#^Method Icinga\\\\Module\\\\Generictts\\\\Ticket\\:\\:init\\(\\) has no return type specified\\.$#" + count: 1 + path: library/Generictts/Ticket.php + + - + message: "#^Parameter \\#1 \\$string of function rawurlencode expects string, string\\|null given\\.$#" + count: 1 + path: library/Generictts/Ticket.php + + - + message: "#^Parameter \\#2 \\$pattern of method Icinga\\\\Application\\\\Hook\\\\TicketHook\\:\\:createTicketPattern\\(\\) expects string, mixed given\\.$#" + count: 1 + path: library/Generictts/Ticket.php + + - + message: "#^Parameter \\#3 \\$subject of function preg_replace expects array\\|string, mixed given\\.$#" + count: 1 + path: library/Generictts/Ticket.php diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..3f551c5 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,26 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: max + + checkFunctionNameCase: true + checkInternalClassCaseSensitivity: true + treatPhpDocTypesAsCertain: false + + paths: + - application + - library + + scanDirectories: + - vendor + + ignoreErrors: + - + messages: + - '#Unsafe usage of new static\(\)#' + - '#. but return statement is missing#' + reportUnmatched: false + + universalObjectCratesClasses: + - Icinga\Web\View From 1eb2d0a44bd07a1e41503de8ba7ccc0d4bb82c1a Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Wed, 30 Aug 2023 15:21:31 +0200 Subject: [PATCH 3/3] Github Actions: Do not cancel further tests if one fails --- .github/workflows/php.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index ec14747..677ab24 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -38,13 +38,13 @@ jobs: git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty - name: PHP Lint - if: success() || matrix.allow_failure + if: ${{ ! cancelled() }} run: ./vendor/bin/phplint -n --exclude={^vendor/.*} -- . - name: PHP CodeSniffer - if: success() || matrix.allow_failure + if: ${{ ! cancelled() }} run: phpcs - name: PHPStan + if: ${{ ! cancelled() }} uses: php-actions/phpstan@v3 - if: success() || matrix.allow_failure