Skip to content

Commit

Permalink
Add check by PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeliot-Tm committed May 21, 2024
1 parent 9fd84f5 commit 8b15f09
Show file tree
Hide file tree
Showing 5 changed files with 241 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .github/workflows/automated_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,34 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate --strict

phpstan:
name: Static analyze with PHPStan
runs-on: ubuntu-latest

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2

- uses: actions/checkout@v4

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: "${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}"
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Static analyze with PHPStan
run: |
composer run phpstan-clear && \
composer run phpstan-analyse -- --no-progress
phpunit:
name: 'Tests: Unit'
runs-on: ubuntu-latest
Expand Down
20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"friendsofphp/php-cs-fixer": "^3.50"
},
"require-dev": {
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-phpunit": "^1.4",
"phpunit/phpunit": "^11.1"
},
"autoload": {
Expand All @@ -25,7 +28,24 @@
"Aeliot\\PhpCsFixerBaseline\\Test\\": "tests/"
}
},
"config": {
"allow-plugins": {
"composer/*": true,
"phpstan/extension-installer": true
},
"sort-packages": true
},
"scripts": {
"phpstan": [
"@phpstan-clear",
"@phpstan-analyse"
],
"phpstan-analyse": "vendor/bin/phpstan analyse --memory-limit=-1",
"phpstan-baseline": [
"@phpstan-clear",
"@phpstan-analyse --generate-baseline phpstan-baseline.neon --allow-empty-baseline"
],
"phpstan-clear": "vendor/bin/phpstan clear-result-cache",
"phpunit": "vendor/bin/phpunit"
}
}
156 changes: 155 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$configHash of method Aeliot\\\\PhpCsFixerBaseline\\\\Model\\\\BaselineContent\\:\\:setConfigHash\\(\\) expects string, int given\\.$#"
count: 1
path: src/Service/Builder.php

-
message: "#^Method Aeliot\\\\PhpCsFixerBaseline\\\\Service\\\\FileCacheCalculator\\:\\:calculate\\(\\) should return string but returns int\\.$#"
count: 1
path: src/Service/FileCacheCalculator.php

-
message: "#^Negated boolean expression is always true\\.$#"
count: 1
path: src/Service/FilterFactory.php

-
message: "#^Result of \\|\\| is always true\\.$#"
count: 1
path: src/Service/FilterFactory.php

-
message: "#^Strict comparison using \\=\\=\\= between string\\|null and int will always evaluate to false\\.$#"
count: 1
path: src/Service/FilterFactory.php
12 changes: 12 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
includes:
- phpstan-baseline.neon

parameters:
level: 6
reportUnmatchedIgnoredErrors: false

paths:
- src/

parallel:
processTimeout: 300.0

0 comments on commit 8b15f09

Please sign in to comment.