Skip to content

PHPStan Static Analysis #9209

PHPStan Static Analysis

PHPStan Static Analysis #9209

name: "PHPStan Static Analysis"
on:
workflow_dispatch:
schedule:
- cron: '0 3 * * *'
pull_request_target:
branches:
- "12.*"
paths-ignore:
- 'doc/**'
- 'bundles/**/public/**'
push:
branches:
- "12.*"
- "*_actions"
paths-ignore:
- 'doc/**'
- 'bundles/**/public/**'
env:
PIMCORE_INSTANCE_IDENTIFIER: ${{ secrets.PIMCORE_CI_INSTANCE_IDENTIFIER }}
PIMCORE_ENCRYPTION_SECRET: ${{ secrets.PIMCORE_CI_ENCRYPTION_SECRET }}
PIMCORE_PRODUCT_KEY: ${{ secrets.PIMCORE_CI_PRODUCT_KEY }}
PIMCORE_PROJECT_ROOT: ${{ github.workspace }}
APP_ENV: test
PIMCORE_TEST: 1
PIMCORE_STORAGE: 'local'
permissions:
contents: read
jobs:
static-analysis-phpstan:
name: "Static Analysis with PHPStan"
runs-on: "ubuntu-latest"
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
include:
- { php-version: "8.3", dependencies: "lowest", experimental: false, symfony: "", composer-options: "" }
- { php-version: "8.3", dependencies: "highest", experimental: false, symfony: "", composer-options: "" }
- { php-version: "8.4", dependencies: "lowest", experimental: false, symfony: "", composer-options: "" }
- { php-version: "8.4", dependencies: "highest", experimental: false, symfony: "", composer-options: "" }
steps:
- name: Checkout PR head (only for pull_request_target)
if: github.event_name == 'pull_request_target'
uses: "actions/checkout@v4"
with:
ref: "refs/pull/${{ github.event.pull_request.number }}/merge"
- name: Checkout PR head (for push or other events)
if: github.event_name != 'pull_request_target'
uses: "actions/checkout@v4"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
- name: "Setup Pimcore environment"
run: |
.github/ci/scripts/setup-pimcore-environment.sh
- name: "Set Symfony version constraint in composer.json"
env:
SYMFONY_VERSION: "${{ matrix.symfony }}"
run: |
if [ ! -z "$SYMFONY_VERSION" ]; then
.github/ci/scripts/symfony-require-dev.sh
fi
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-options }}"
- name: "Run a static analysis with phpstan/phpstan (highest)"
if: ${{ matrix.dependencies == 'highest' }}
run: "vendor/bin/phpstan analyse --memory-limit=-1"
- name: "Run a static analysis with phpstan/phpstan (lowest)"
if: ${{ matrix.dependencies == 'lowest' }}
run: "vendor/bin/phpstan analyse --memory-limit=-1 -c phpstan-lowest.neon"
- name: "Generate baseline file"
if: ${{ failure() }}
run: "vendor/bin/phpstan analyse --memory-limit=-1 --generate-baseline"
- name: "Upload baseline file"
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: phpstan-baseline.neon
path: phpstan-baseline.neon