From d45c3308f2577cc44c0b9c763d49424383e2541b Mon Sep 17 00:00:00 2001 From: Steve Grunwell <233836+stevegrunwell@users.noreply.github.com> Date: Mon, 11 Dec 2023 19:47:16 -0500 Subject: [PATCH] Install Phan for static code analysis --- .github/workflows/static-code-analysis.yml | 23 ++++++++++++++++++++++ .gitignore | 3 +++ composer.json | 5 +++++ phpstan.neon.dist | 7 +++++++ 4 files changed, 38 insertions(+) create mode 100644 .github/workflows/static-code-analysis.yml create mode 100644 phpstan.neon.dist diff --git a/.github/workflows/static-code-analysis.yml b/.github/workflows/static-code-analysis.yml new file mode 100644 index 0000000..38397a9 --- /dev/null +++ b/.github/workflows/static-code-analysis.yml @@ -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 diff --git a/.gitignore b/.gitignore index 29813da..415274e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ *.DS_Store .phpunit.result.cache .vscode +phpcs.xml +phpstan.neon +phpunit.xml tests/coverage vendor diff --git a/composer.json b/composer.json index 59b6172..0e10181 100644 --- a/composer.json +++ b/composer.json @@ -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" }, @@ -39,6 +40,9 @@ "coding-standards": [ "phpcs" ], + "static-analysis": [ + "phpstan analyse" + ], "test": [ "simple-phpunit --testdox" ], @@ -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." }, diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..b980ecc --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,7 @@ +parameters: + level: 6 + paths: + - src + - tests + excludePaths: + - tests/coverage