Skip to content

Commit 9961e9a

Browse files
committed
Add phpstan and psalm for static analysis
1 parent bac904f commit 9961e9a

6 files changed

Lines changed: 63 additions & 1 deletion

File tree

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
/.gitattributes export-ignore
66
/.github export-ignore
77
/.gitignore export-ignore
8+
/phpstan.neon.dist export-ignore
89
/phpunit.xml.dist export-ignore
10+
/psalm.xml.dist export-ignore
911
/tests export-ignore

.github/workflows/tests.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,39 @@ jobs:
4141

4242
- run: vendor/bin/phpunit --coverage-text
4343
if: ${{ matrix.coverage }}
44+
45+
phpstan:
46+
name: PHPStan
47+
runs-on: ubuntu-latest
48+
49+
steps:
50+
- uses: actions/checkout@v2
51+
52+
- uses: shivammathur/setup-php@v2
53+
with:
54+
php-version: 7.1
55+
extensions: curl
56+
coverage: none
57+
tools: composer:v2
58+
59+
- run: composer update --no-progress
60+
61+
- run: vendor/bin/phpstan analyse --no-progress
62+
63+
psalm:
64+
name: Psalm
65+
runs-on: ubuntu-latest
66+
67+
steps:
68+
- uses: actions/checkout@v2
69+
70+
- uses: shivammathur/setup-php@v2
71+
with:
72+
php-version: 7.1
73+
extensions: curl
74+
coverage: none
75+
tools: composer:v2
76+
77+
- run: composer update --no-progress
78+
79+
- run: vendor/bin/psalm --no-progress --output-format=github

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.phpunit.result.cache
22
composer.lock
3+
phpstan.neon
34
phpunit.xml
5+
psalm.xml
46
vendor

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"php": "^7.1 || ^8.0"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.3"
29+
"phpstan/phpstan": "^0.12.42",
30+
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.3",
31+
"vimeo/psalm": "^3.14"
3032
},
3133
"autoload": {
3234
"psr-4": {

phpstan.neon.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- src

psalm.xml.dist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
totallyTyped="false"
4+
errorLevel="3"
5+
resolveFromConfigFile="true"
6+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7+
xmlns="https://getpsalm.org/schema/config"
8+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
9+
>
10+
<projectFiles>
11+
<directory name="src" />
12+
<ignoreFiles>
13+
<directory name="vendor" />
14+
</ignoreFiles>
15+
</projectFiles>
16+
</psalm>

0 commit comments

Comments
 (0)