Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Phan for static code analysis #48

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
php-version: ${{ matrix.php-version }}
coverage: none

- name: Remove PHPStan as a dependency
run: composer remove --dev phpstan/phpstan

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

Expand Down
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
Loading