Skip to content

Commit ffda7c3

Browse files
authored
Add PHPStan for static analysis (#905)
1 parent a11ecf6 commit ffda7c3

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ jobs:
4646
CI_PHP_VERSION: ${{ matrix.php-version }}
4747
CI_PHP_FUTURE_RELEASE: ${{ matrix.future-release }}
4848

49-
- name: Static analysis
49+
- name: Static analysis - Psalm
5050
run: 'vendor/bin/psalm --config="tests/psalm.xml"'
5151
# TODO: Remove exclusion that skips running psalm on PHP 8.4 when psalm
5252
# supports PHP 8.4 (https://github.com/vimeo/psalm/issues/11107).
53-
if: ${{ !matrix.future-release && matrix.php-version < 8.4 }}
53+
if: ${{ matrix.php-version < 8.4 }}
54+
55+
- name: Static analysis - PHPStan
56+
run: 'vendor/bin/phpstan analyse --configuration="phpstan.neon" .'
57+
if: ${{ matrix.php-version >= 7.4 }}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"friendsofphp/php-cs-fixer": "*",
2828
"phpcompatibility/php-compatibility": "dev-develop",
2929
"phpcsstandards/phpcsutils": "@alpha",
30+
"phpstan/phpstan": "*",
3031
"phpunit/phpunit": "*",
3132
"squizlabs/php_codesniffer": "*"
3233
},

phpstan-baseline.neon

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Class CurlHandle not found\.$#'
5+
identifier: class.notFound
6+
count: 2
7+
path: src/Curl/Curl.php
8+
9+
-
10+
message: '#^Class CurlMultiHandle not found\.$#'
11+
identifier: class.notFound
12+
count: 2
13+
path: src/Curl/MultiCurl.php

phpstan.neon

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
reportUnmatchedIgnoredErrors: false
6+
7+
# TODO: Increase rule level to be more strict.
8+
level: 0
9+
10+
# TODO: Remove all exclusions except vendor/ and fix related errors.
11+
excludePaths:
12+
- examples/*
13+
- tests/*
14+
- vendor/*
15+
- www/*

0 commit comments

Comments
 (0)