Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added phpstan config with baseline #126

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
/docker-compose.yml
/tests export-ignore
/tools export-ignore

/phpstan.dist.neon export-ignore
48 changes: 48 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Static Analysis

on:
pull_request:
branches:
- master
paths:
- .github/workflows/static-analysis.yml
- tests/StaticAnalysis/*
- composer.*
- lib/**
- phpstan*

push:
branches:
- master
paths:
- .github/workflows/static-analysis.yml
- tests/StaticAnalysis/*
- composer.*
- lib/**
- phpstan*

jobs:
static-analysis-phpstan:
name: Static Analysis with PHPStan
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: 8.3
tools: cs2pr

- name: Install dependencies with Composer
Copy link
Member

@thePanz thePanz Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to simplify this action and introduce a composer cache like suggested here:

https://github.com/shivammathur/setup-php?tab=readme-ov-file#cache-composer-dependencies

Something like:

- name: Get composer cache directory
  id: composer-cache
  run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
  uses: actions/cache@v4
  with:
    path: ${{ steps.composer-cache.outputs.dir }}
    key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
    restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
  run: composer install --prefer-dist```

uses: ramsey/composer-install@v2

- name: Run static analysis w/ phpVersion 74
run: vendor/bin/phpstan analyse -c tests/StaticAnalysis/phpstan-74.neon --error-format=checkstyle | cs2pr

- name: Run static analysis w/ phpVersion 83
run: vendor/bin/phpstan analyse -c tests/StaticAnalysis/phpstan-83.neon --error-format=checkstyle | cs2pr

10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"ext-pdo": "*",
"ext-zlib": "*"
},
"require-dev": {
"phpstan/phpstan": "^1.10"
},
"support": {
"issues": "https://github.com/FriendsOfSymfony1/doctrine1/issues",
"source": "https://github.com/FriendsOfSymfony1/doctrine1"
Expand All @@ -42,5 +45,12 @@
},
"config": {
"sort-packages": true
},
"scripts": {
"analyse": [
"@phpstan83"
],
"phpstan74": "phpstan analyse -c tests/StaticAnalysis/phpstan-74.neon --memory-limit=500M",
"phpstan83": "phpstan analyse -c tests/StaticAnalysis/phpstan-83.neon --memory-limit=500M"
}
}
6 changes: 6 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
phpVersion: 80300

includes:
- tests/StaticAnalysis/phpstan-params.neon
- tests/StaticAnalysis/phpstan-baseline-83.php
6 changes: 6 additions & 0 deletions tests/StaticAnalysis/phpstan-74.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
phpVersion: 70400

includes:
- phpstan-params.neon
- phpstan-baseline-74.php
6 changes: 6 additions & 0 deletions tests/StaticAnalysis/phpstan-83.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
phpVersion: 80300

includes:
- phpstan-params.neon
- phpstan-baseline-83.php
Loading
Loading