Skip to content

Commit

Permalink
Add PHPStan to the workflow (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg authored Aug 31, 2023
2 parents c66a6f9 + 1eb2d0a commit 5e5ccef
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -31,12 +31,20 @@ 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
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
96 changes: 96 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5e5ccef

Please sign in to comment.