GitHub Action
PHPStan (php-actions)
PHPStan finds bugs in your code without writing tests by using runnin static analysis on your project's code.
Create your Github Workflow configuration in .github/workflows/ci.yml
or similar.
name: CI
on: [push]
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: php-actions/composer@v5 # or alternative dependency management
- uses: php-actions/phpstan@v2
# ... then your own project steps ...
We've put together an extremely simple example application that uses php-actions/phpstan
. Check it out here: https://github.com/php-actions/example-phpstan.
The following configuration options are available:
version
The version of PHPUnit to use e.g.9
or9.5.0
(default: latest)php_version
The version of PHP to use e.g.7.4
(default: latest)php_extensions
Space-separated list of extensions using php-build e.g.xdebug mbstring
(default: N/A)command
The command to run e.g.list
orworker
(default: analyse)path
Path(s) with source code to run analysis on (required)configuration
Configuration file locationlevel
Level of rule options - the higher, the stricterpaths_file
Path to a file with a list of paths to run analysis onautoload_file
Project's additional autoload file patherror_format
Format in which to print the result of the analysisgenerate_baseline
Path to a file where the baseline should be savedmemory_limit
Memory limit for analysisargs
Extra arguments to pass to the phpstan binary
By default, adding - uses: php-actions/phpstan@v2 into your workflow will run phpstan analyse
, as analyse
is the default command name.
You can issue custom commands by passing a command input, like so:
jobs:
phpstan:
...
- name: PHPStan
uses: php-actions/phpstan@v2
with:
command: your-command-here
The syntax for passing in a custom input is the following:
...
jobs:
phpstan:
...
- name: PHPStan Static Analysis
uses: php-actions/phpstan@v2
with:
configuration: custom/path/to/phpstan.neon
memory_limit: 256M
If you require other configurations of phpstan, please request them in the Github issue tracker
It's possible to run any version of PHPStan under any version of PHP, with any PHP extensions you require. This is configured with the following inputs:
version
- the version number of PHPStan to run e.g.0.12.63
(default: latest)php_version
- the version number of PHP to use e.g.7.4
(default: latest)php_extensions
- a space-separated list of extensions to install using php-build e.g.xdebug mbstring
(default: N/A)
If you require a specific version combination that is not compatible with Github Actions for some reason, please make a request in the Github issue tracker.
If you found this repository helpful, please consider sponsoring the developer.