Skip to content

Commit 816c8d1

Browse files
committed
chore: add Larastan for static analysis and CI workflow
Add Larastan as a development dependency to enable static code analysis for the Laravel project. This helps in identifying potential bugs and improving code quality without running the application. Additionally, a GitHub Actions CI workflow is introduced to automate testing, static analysis, and code style checks on every push or pull request. The workflow includes steps for PHP setup, dependency installation, PHPUnit tests, PHPStan analysis, and Pint code style verification. A `phpstan.neon` configuration file is also added to customize the static analysis process, including paths to analyze and the desired level of strictness.
1 parent 876cff8 commit 816c8d1

File tree

4 files changed

+286
-4
lines changed

4 files changed

+286
-4
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Set up PHP
11+
uses: shivammathur/setup-php@v2
12+
with:
13+
php-version: '8.0'
14+
- name: Install dependencies
15+
run: composer install --prefer-dist --no-progress --no-suggest
16+
- name: Run PHPUnit tests
17+
run: vendor/bin/phpunit
18+
- name: Run PHPStan analysis
19+
run: vendor/bin/phpstan analyse
20+
- name: Check code style
21+
run: vendor/bin/pint --test

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"require-dev": {
1515
"fakerphp/faker": "^1.9.1",
16+
"larastan/larastan": "^2.3",
1617
"laravel/pint": "^1.0",
1718
"laravel/sail": "^1.0.1",
1819
"mockery/mockery": "^1.4.4",

composer.lock

Lines changed: 247 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
includes:
2+
- vendor/larastan/larastan/extension.neon
3+
- vendor/nesbot/carbon/extension.neon
4+
5+
parameters:
6+
7+
paths:
8+
- app/
9+
10+
# Level 10 is the highest level
11+
level: 5
12+
13+
# ignoreErrors:
14+
# - '#PHPDoc tag @var#'
15+
#
16+
# excludePaths:
17+
# - ./*/*/FileToBeExcluded.php

0 commit comments

Comments
 (0)