Skip to content

Commit

Permalink
static-analysis-php // init commit to support PHPStan.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrico committed Dec 18, 2024
1 parent d3cda33 commit d364a0a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/static-analysis-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ on:
default: '--output-format=github --no-cache'
required: false
type: string
PHPSTAN_ARGS:
description: Set of arguments passed to PHPStan.
default: ' --no-progress --memory-limit=1G'
required: false
type: string
secrets:
COMPOSER_AUTH_JSON:
description: Authentication for privately hosted packages and repositories as a JSON formatted object.
Expand Down Expand Up @@ -63,4 +68,9 @@ jobs:
composer-options: ${{ inputs.COMPOSER_ARGS }}

- name: Run Psalm
if: ${{ hashFiles('psalm.xml') }}
run: ./vendor/bin/psalm --php-version="${{ inputs.PHP_VERSION }}" ${{ inputs.PSALM_ARGS }}

- name: Run PHPStan
if: ${{ hashFiles('phpstan.neon.dist, phpstan.neon, phpstan.dist.neon') }}
run: ./vendor/bin/phpstan ${{ inputs.PSALM_ARGS }}
13 changes: 11 additions & 2 deletions docs/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,16 @@ versions.

## Static code analysis

This workflow runs [Psalm](https://psalm.dev/). It does so by executing the binary in the
`./vendor/bin/` folder.
This workflow runs [Psalm](https://psalm.dev/) or [PHPStan](https://phpstan.org/) by looking for the configuration files in your repository root folder.

It does so by executing the binary in the `./vendor/bin/` folder.

**Supported configuration files:**

| tool | file(s) |
|-----------|----------------------------------------------------------|
| `psalm` | `psalm.xml` |
| `phpstan` | `phpstan.neon.dist`, `phpstan.neon`, `phpstan.dist.neon` |

**Simplest possible example:**

Expand All @@ -85,6 +93,7 @@ jobs:
| `PHP_VERSION` | `'8.2'` | PHP version with which the scripts are executed |
| `COMPOSER_ARGS` | `'--prefer-dist'` | Set of arguments passed to Composer |
| `PSALM_ARGS` | `'--output-format=github --no-cache'` | Set of arguments passed to Psalm |
| `PSALM_ARGS` | `'--output-format=github --no-cache'` | Set of arguments passed to PHPStan |

#### Secrets

Expand Down

0 comments on commit d364a0a

Please sign in to comment.