Skip to content

zeroseven/action-phpstan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

PHPStan Analysis Action

GitHub Action to run PHPStan static analysis on PHP code.

Features

  • ✅ 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

Usage

- uses: zeroseven/action-phpstan@v1
  with:
    config: 'phpstan.neon'
    paths: 'src/'

Inputs

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

Examples

Basic Usage

steps:
  - uses: actions/checkout@v4
  - uses: zeroseven/action-php-build@v1
  - uses: zeroseven/action-phpstan@v1
    with:
      config: 'phpstan.neon'
      paths: 'packages/'

With Custom Level

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'

Higher Memory Limit

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'

Required Files

Your project must include a phpstan.neon configuration file. Example:

parameters:
    level: 8
    paths:
        - src
    excludePaths:
        - tests

Caching

This 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.lock or phpstan.neon changes
  • Manual clear: Delete caches in repository Settings → Actions → Caches

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published