Skip to content

Commit 1f28fa3

Browse files
authored
Merge pull request #26 from fhict-skilltree/25-install-static-code-analysis-tool-phpstan
Install static code analysis tool phpstan
2 parents 8a16ed6 + 02c69ac commit 1f28fa3

File tree

6 files changed

+285
-1
lines changed

6 files changed

+285
-1
lines changed

.github/workflows/ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ jobs:
8181
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
8282
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
8383

84+
- name: Static analyses with Larastan (PHPStan)
85+
run: composer run analyse
86+
continue-on-error: true
87+
8488
- name: Upload coverage to Codecov
8589
uses: codecov/codecov-action@v4-beta
8690
env:

composer.json

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"laravel/sail": "^1.18",
1818
"mockery/mockery": "^1.4.4",
1919
"nunomaduro/collision": "^7.0",
20+
"nunomaduro/larastan": "^2.0",
2021
"phpunit/phpunit": "^10.1",
2122
"spatie/laravel-ignition": "^2.0"
2223
},
@@ -40,6 +41,8 @@
4041
"pint-dirty": "./vendor/bin/pint --dirty",
4142
"pint-test": "./vendor/bin/pint --test",
4243
"pint-test-dirty": "./vendor/bin/pint --test --dirty",
44+
"analyse": "./vendor/bin/phpstan analyse --memory-limit=2G",
45+
"analyse-baseline": "./vendor/bin/phpstan analyse --generate-baseline phpstan-baseline.php --memory-limit=2G",
4346
"post-autoload-dump": [
4447
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
4548
"@php artisan package:discover --ansi"

composer.lock

+246-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/technical/architecture/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: default
33
title: Software Architecture
44
nav_order: 3
55
has_children: true
6+
parent: Technical Documentation
67
permalink: /docs/technical/architecture
78
---
89

docs/technical/local-development.md

+16
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,19 @@ composer run pint-test
7373
# Test the code style of the changes you made
7474
composer run pint-test-dirty
7575
```
76+
77+
## Static code analyses (PHPStan)
78+
79+
We've implemented Larastan (PHPStan) to analyse our code statically. It will search for type errors in the codebase.
80+
81+
To run the static code analyses locally, you can run:
82+
83+
```shell
84+
composer run analyse
85+
```
86+
87+
To generate a new baseline, you can run:
88+
89+
```shell
90+
composer run analyse-baseline
91+
```

phpstan.neon

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
includes:
2+
- ./vendor/nunomaduro/larastan/extension.neon
3+
4+
parameters:
5+
paths:
6+
- app/
7+
- config/
8+
9+
excludePaths:
10+
- tests
11+
12+
# Level 9 is the highest level
13+
level: 5
14+
15+
checkMissingIterableValueType: false

0 commit comments

Comments
 (0)