Skip to content

Commit

Permalink
Feature/phpstan (#172)
Browse files Browse the repository at this point in the history
* static-analysis-php // init commit to support PHPStan.
* Update static-analysis-php.yml
* Update php.md
* update docs
* fix PHP QA workflow
* Update .github/workflows/static-analysis-php.yml

Co-authored-by: Thorsten Frommen <[email protected]>
Signed-off-by: Christian Leucht <[email protected]>

* alphabetically sort config file patterns

Co-authored-by: Philipp Bammes <[email protected]>
Signed-off-by: Thorsten Frommen <[email protected]>

---------

Signed-off-by: Christian Leucht <[email protected]>
Signed-off-by: Thorsten Frommen <[email protected]>
Co-authored-by: tfrommen <[email protected]>
Co-authored-by: Philipp Bammes <[email protected]>
  • Loading branch information
3 people authored Jan 7, 2025
1 parent 25f252c commit 6a635a6
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', 'psalm.xml.dist') != '' }}
run: ./vendor/bin/psalm --php-version="${{ inputs.PHP_VERSION }}" ${{ inputs.PSALM_ARGS }}

- name: Run PHPStan
if: ${{ hashFiles('phpstan.dist.neon', 'phpstan.neon', 'phpstan.neon.dist') != '' }}
run: ./vendor/bin/phpstan ${{ inputs.PHPSTAN_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 either [Psalm](https://psalm.dev/) or [PHPStan](https://phpstan.org/), or both, based on the existence of a supported configuration file in your repository root folder.

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

**Supported configuration files:**

| Tool | Files |
|---------|----------------------------------------------------------|
| Psalm | `psalm.xml`, `psalm.xml.dist` |
| PHPStan | `phpstan.dist.neon`, `phpstan.neon`, `phpstan.neon.dist` |

**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 |
| `PHPSTAN_ARGS` | `'--no-progress --memory-limit=1G'` | Set of arguments passed to PHPStan |

#### Secrets

Expand Down

0 comments on commit 6a635a6

Please sign in to comment.