Skip to content

Commit

Permalink
Install Phan for static code analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegrunwell committed Dec 12, 2023
1 parent 2d3a414 commit d45c330
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/static-code-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Static Code Analysis

on: [pull_request]

jobs:
phpcs:
name: PHPStan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: none

- name: Install Composer dependencies
uses: ramsey/composer-install@v2

- name: Run PHPStan
run: composer static-analysis
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
*.DS_Store
.phpunit.result.cache
.vscode
phpcs.xml
phpstan.neon
phpunit.xml
tests/coverage
vendor

Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^1.10",
"squizlabs/php_codesniffer": "^3.7",
"symfony/phpunit-bridge": "^5.2 || ^6.2"
},
Expand All @@ -39,6 +40,9 @@
"coding-standards": [
"phpcs"
],
"static-analysis": [
"phpstan analyse"
],
"test": [
"simple-phpunit --testdox"
],
Expand All @@ -48,6 +52,7 @@
},
"scripts-descriptions": {
"coding-standards": "Check coding standards.",
"static-analysis": "Run static code analysis",
"test": "Run all test suites.",
"test-coverage": "Generate code coverage reports in tests/coverage."
},
Expand Down
7 changes: 7 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
level: 6
paths:
- src
- tests
excludePaths:
- tests/coverage

0 comments on commit d45c330

Please sign in to comment.