Skip to content

Commit e7fa997

Browse files
committed
feat: implement psalm
Signed-off-by: Vitor Mattos <[email protected]>
1 parent 395cc0d commit e7fa997

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-0
lines changed

.github/workflows/psalm.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Static analysis
2+
3+
on: pull_request
4+
5+
concurrency:
6+
group: psalm-${{ github.head_ref || github.run_id }}
7+
cancel-in-progress: true
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
static-analysis:
14+
runs-on: ubuntu-latest
15+
16+
name: static-psalm-analysis
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
20+
with:
21+
persist-credentials: false
22+
23+
- name: Get php version
24+
id: versions
25+
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
26+
27+
- name: Check enforcement of minimum PHP version ${{ steps.versions.outputs.php-min }} in psalm.xml
28+
run: grep 'phpVersion="${{ steps.versions.outputs.php-min }}' psalm.xml
29+
30+
- name: Set up php${{ steps.versions.outputs.php-available }}
31+
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # v2.35.4
32+
with:
33+
php-version: ${{ steps.versions.outputs.php-available }}
34+
coverage: none
35+
ini-file: development
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Install dependencies
40+
run: composer i
41+
42+
- name: Run coding standards check
43+
run: composer run psalm -- --output-format=github

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
"@composer bin all install --ansi",
3838
"composer dump-autoload"
3939
],
40+
"psalm": "psalm --no-cache --threads=$(nproc)",
41+
"psalm:update-baseline": "psalm --threads=$(nproc) --update-baseline --set-baseline=tests/psalm-baseline.xml",
4042
"post-update-cmd": [
4143
"composer dump-autoload"
4244
],

psalm.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorBaseline="tests/psalm-baseline.xml"
4+
errorLevel="5"
5+
findUnusedBaselineEntry="true"
6+
findUnusedCode="false"
7+
resolveFromConfigFile="true"
8+
phpVersion="8.1"
9+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xmlns="https://getpsalm.org/schema/config"
11+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor-bin/psalm/vendor/vimeo/psalm/config.xsd"
12+
>
13+
<projectFiles>
14+
<directory name="src" />
15+
<ignoreFiles>
16+
<directory name="vendor" />
17+
</ignoreFiles>
18+
</projectFiles>
19+
<issueHandlers>
20+
<LessSpecificReturnStatement errorLevel="error"/>
21+
<LessSpecificReturnType errorLevel="error"/>
22+
<LessSpecificImplementedReturnType errorLevel="error"/>
23+
<MoreSpecificReturnType errorLevel="error"/>
24+
</issueHandlers>
25+
</psalm>

tests/psalm-baseline.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<files psalm-version="6.13.1@1e3b7f0a8ab32b23197b91107adc0a7ed8a05b51"/>

vendor-bin/psalm/composer.json

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

0 commit comments

Comments
 (0)