GitHub Action to run PHPStan static analysis on PHP code.
- ✅ Validates config file exists
- ✅ GitHub-formatted error output
- ✅ Configurable memory limit
- ✅ Flexible path and level configuration
- ✅ Automatic result caching - Caches
.phpstan/directory for 60% faster runs
- uses: zeroseven/action-phpstan@v1
with:
config: 'phpstan.neon'
paths: 'src/'| Input | Description | Required | Default |
|---|---|---|---|
php-version |
PHP version to use | No | 8.3 |
config |
Path to phpstan.neon | Yes | - |
paths |
Paths to analyze | No | . |
level |
Analysis level (0-9, or max) | No | - |
memory-limit |
Memory limit | No | 1G |
error-format |
Error output format | No | github |
steps:
- uses: actions/checkout@v4
- uses: zeroseven/action-php-build@v1
- uses: zeroseven/action-phpstan@v1
with:
config: 'phpstan.neon'
paths: 'packages/'steps:
- uses: actions/checkout@v4
- uses: zeroseven/action-php-build@v1
- uses: zeroseven/action-phpstan@v1
with:
config: 'phpstan.neon'
paths: 'src/ tests/'
level: '8'steps:
- uses: actions/checkout@v4
- uses: zeroseven/action-php-build@v1
- uses: zeroseven/action-phpstan@v1
with:
config: 'phpstan.neon'
paths: 'app/'
memory-limit: '2G'Your project must include a phpstan.neon configuration file. Example:
parameters:
level: 8
paths:
- src
excludePaths:
- testsThis action automatically caches PHPStan's result cache (.phpstan/ directory) to speed up subsequent runs.
Cache Key Strategy:
- Primary:
phpstan-{OS}-{PHP version}-{composer.lock hash}-{config hash} - Fallback:
phpstan-{OS}-{PHP version}-
Expected Performance:
- First run: 1-2 minutes
- Cached run: 15-30 seconds (~60% faster)
Cache Invalidation:
- Cache automatically refreshes when
composer.lockorphpstan.neonchanges - Manual clear: Delete caches in repository Settings → Actions → Caches
MIT