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

Add PHPStan to the workflow #25

Merged
merged 3 commits into from
Aug 31, 2023
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
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
Loading