Skip to content

Commit eca3531

Browse files
committed
ci(phpstan): Test PHPStan
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent 368d687 commit eca3531

File tree

6 files changed

+153
-4
lines changed

6 files changed

+153
-4
lines changed

.github/workflows/phpstan.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
name: PHPStan
10+
11+
on: pull_request
12+
13+
concurrency:
14+
group: phpstan-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
phpstan-static-analysis:
19+
runs-on: ubuntu-latest
20+
21+
name: static-phpstan-analysis
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
with:
26+
persist-credentials: false
27+
28+
- name: Get php version
29+
id: versions
30+
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
31+
32+
- name: Set up php${{ steps.versions.outputs.php-available }}
33+
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
34+
with:
35+
php-version: ${{ steps.versions.outputs.php-available }}
36+
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
37+
coverage: none
38+
ini-file: development
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Install dependencies
43+
run: composer i
44+
45+
- name: Run static analysis
46+
run: composer run phpstan

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"cs:check": "php-cs-fixer fix --dry-run --diff",
2424
"cs:fix": "php-cs-fixer fix",
2525
"openapi": "generate-spec",
26+
"phpstan": "vendor/bin/phpstan analyse -c phpstan.neon",
2627
"psalm": "psalm --no-cache --threads=$(nproc)",
2728
"psalm:dev": "@psalm",
2829
"psalm:update-baseline": "psalm --threads=1 --update-baseline",

composer.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
parameters:
4+
level: 5
5+
paths:
6+
- lib
7+
scanFiles:
8+
- tests/stub.phpstub
9+
scanDirectories:
10+
- vendor/nextcloud/ocp
11+
ignoreErrors:
12+
- '#on an unknown class Doctrine\\DBAL\\Schema\\Table#'

vendor-bin/phpstan/composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"config": {
3+
"platform": {
4+
"php": "8.1"
5+
}
6+
},
7+
"require-dev": {
8+
"phpstan/phpstan": "^2.1.0"
9+
}
10+
}

vendor-bin/phpstan/composer.lock

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)