Workflow: Add PHPStan static analyzer

This commit is contained in:
raviks789 2023-08-31 11:24:56 +02:00 committed by Thomas Gelf
parent 132d49777a
commit 69a3e9aa8e
2 changed files with 73 additions and 1 deletions

View File

@ -31,7 +31,46 @@ jobs:
tools: phpcs tools: phpcs
- name: Setup dependencies - name: Setup dependencies
run: composer require -n --no-progress overtrue/phplint run: |
composer require -n --no-progress overtrue/phplint phpunit/phpunit ipl/stdlib:@dev ipl/html:@dev
git clone --depth 1 https://github.com/Icinga/icingaweb2.git vendor/icingaweb2
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty
git clone --depth 1 https://github.com/Icinga/icingaweb2-module-cube.git vendor/cube
- name: Setup Incubator
run: |
git clone --depth 1 https://github.com/Icinga/icingaweb2-module-incubator vendor/incubator
cd vendor/incubator
composer require --no-update \
"gipfl/calendar": "dev-master as 99.x-dev" \
"gipfl/cli": "dev-master as 99.x-dev" \
"gipfl/curl": "dev-master as 99.x-dev" \
"gipfl/data-type": "dev-master as 99.x-dev" \
"gipfl/db-migration": "dev-master as 99.x-dev" \
"gipfl/diff": "dev-master as 99.x-dev" \
"gipfl/format": "dev-master as 99.x-dev" \
"gipfl/icinga-bundles": "dev-master as 99.x-dev" \
"gipfl/icinga-cli-daemon": "dev-master as 99.x-dev" \
"gipfl/icingaweb2": "dev-master as 99.x-dev" \
"gipfl/influxdb": "dev-master as 99.x-dev" \
"gipfl/json": "dev-master as 99.x-dev" \
"gipfl/linux-health": "dev-master as 99.x-dev" \
"gipfl/log": "dev-master as 99.x-dev" \
"gipfl/process": "dev-master as 99.x-dev" \
"gipfl/protocol-jsonrpc": "dev-master as 99.x-dev" \
"gipfl/protocol-netstring": "dev-master as 99.x-dev" \
"gipfl/react-utils": "dev-master as 99.x-dev" \
"gipfl/simple-daemon": "dev-master as 99.x-dev" \
"gipfl/socket": "dev-master as 99.x-dev" \
"gipfl/stream": "dev-master as 99.x-dev" \
"gipfl/systemd": "dev-master as 99.x-dev" \
"gipfl/translation": "dev-master as 99.x-dev" \
"gipfl/web": "dev-master as 99.x-dev" \
"gipfl/zfdb": "dev-master as 99.x-dev" \
"gipfl/zfdbstore": "dev-master as 99.x-dev"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
bin/make-release.sh snapshot
- name: PHP Lint - name: PHP Lint
if: ${{ ! cancelled() }} if: ${{ ! cancelled() }}
@ -41,6 +80,10 @@ jobs:
if: ${{ ! cancelled() }} if: ${{ ! cancelled() }}
run: phpcs run: phpcs
- name: PHPStan
if: ${{ ! cancelled() }}
uses: php-actions/phpstan@v3
test: test:
name: Unit tests with php ${{ matrix.php }} on ${{ matrix.os }} name: Unit tests with php ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}

29
phpstan.neon Normal file
View File

@ -0,0 +1,29 @@
parameters:
level: 2
checkFunctionNameCase: false
checkInternalClassCaseSensitivity: false
treatPhpDocTypesAsCertain: false
paths:
- application
- library/Director
ignoreErrors:
- '#Unsafe usage of new static\(\)#'
- '#. but return statement is missing#'
scanDirectories:
- vendor
- library/Director/Test
excludePaths:
- library/Director/CoreBeta
universalObjectCratesClasses:
- Icinga\Module\Director\Data\Db\DbObject
- Icinga\Data\ConfigObject
- Icinga\Web\View
- Icinga\Module\Monitoring\Object\MonitoredObject
- Icinga\Module\Monitoring\DataView\DataView
- Icinga\Web\Session\SessionNamespace
- Icinga\User\Preferences