Skip to content

Commit 3189686

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

File tree

5 files changed

+80
-0
lines changed

5 files changed

+80
-0
lines changed

.github/workflows/psalm.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
strategy:
16+
matrix:
17+
php:
18+
- "8.1"
19+
- "8.2"
20+
- "8.3"
21+
- "8.4"
22+
23+
name: static-psalm-analysis
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
27+
with:
28+
persist-credentials: false
29+
30+
- name: Set up php${{ matrix.php }}
31+
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # v2.35.4
32+
with:
33+
php-version: ${{ matrix.php }}
34+
coverage: none
35+
ini-file: development
36+
37+
- name: Install dependencies
38+
run: composer install
39+
40+
- name: Run coding standards check
41+
run: vendor/bin/psalm --no-cache --threads=$(nproc) --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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"require-dev": {
3+
"vimeo/psalm": "^5.26"
4+
},
5+
"config": {
6+
"platform": {
7+
"php": "8.1"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)