Skip to content

Commit

Permalink
Merge pull request #48 from stevegrunwell/feature/static-code-analysis
Browse files Browse the repository at this point in the history
Install Phan for static code analysis
  • Loading branch information
stevegrunwell committed Dec 12, 2023
2 parents d2d23d9 + 1fa6e1d commit 62cfbb1
Show file tree
Hide file tree
Showing 5 changed files with 41 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 .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

0 comments on commit 62cfbb1

Please sign in to comment.