Skip to content

Commit 62cfbb1

Browse files
Merge pull request #48 from stevegrunwell/feature/static-code-analysis
Install Phan for static code analysis
2 parents d2d23d9 + 1fa6e1d commit 62cfbb1

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Static Code Analysis
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
phpcs:
7+
name: PHPStan
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
13+
- name: Setup PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: '8.2'
17+
coverage: none
18+
19+
- name: Install Composer dependencies
20+
uses: ramsey/composer-install@v2
21+
22+
- name: Run PHPStan
23+
run: composer static-analysis

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
php-version: ${{ matrix.php-version }}
2020
coverage: none
2121

22+
- name: Remove PHPStan as a dependency
23+
run: composer remove --dev phpstan/phpstan
24+
2225
- name: Install Composer dependencies
2326
uses: ramsey/composer-install@v2
2427

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
*.DS_Store
22
.phpunit.result.cache
33
.vscode
4+
phpcs.xml
5+
phpstan.neon
6+
phpunit.xml
47
tests/coverage
58
vendor
69

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"require-dev": {
2323
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
2424
"phpcompatibility/php-compatibility": "^9.3",
25+
"phpstan/phpstan": "^1.10",
2526
"squizlabs/php_codesniffer": "^3.7",
2627
"symfony/phpunit-bridge": "^5.2 || ^6.2"
2728
},
@@ -39,6 +40,9 @@
3940
"coding-standards": [
4041
"phpcs"
4142
],
43+
"static-analysis": [
44+
"phpstan analyse"
45+
],
4246
"test": [
4347
"simple-phpunit --testdox"
4448
],
@@ -48,6 +52,7 @@
4852
},
4953
"scripts-descriptions": {
5054
"coding-standards": "Check coding standards.",
55+
"static-analysis": "Run static code analysis",
5156
"test": "Run all test suites.",
5257
"test-coverage": "Generate code coverage reports in tests/coverage."
5358
},

phpstan.neon.dist

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
level: 6
3+
paths:
4+
- src
5+
- tests
6+
excludePaths:
7+
- tests/coverage

0 commit comments

Comments
 (0)