Skip to content

Commit 887bb8c

Browse files
authored
Merge pull request #285 from Kit/lint-code-php7.1
Run PHPStan against PHP 7.1+
2 parents 4ef79f2 + 7f0a29e commit 887bb8c

4 files changed

Lines changed: 45 additions & 13 deletions

File tree

.github/workflows/coding-standards.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,4 @@ jobs:
151151
# Run PHPStan for static analysis.
152152
- name: Run PHPStan Static Analysis
153153
working-directory: ${{ env.PLUGIN_DIR }}
154-
if: ${{ contains('8.0 8.1 8.2 8.3 8.4', matrix.php-versions) }}
155154
run: php vendor/bin/phpstan analyse --memory-limit=1024M

phpstan-dev.neon

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ includes:
66

77
# Parameters
88
parameters:
9+
# Analyse against the minimum supported PHP version.
10+
# This flags features (union types, enums, str_contains, etc.) that would
11+
# fail on older PHP versions regardless of which PHP version PHPStan runs on.
12+
phpVersion: 70100
13+
914
# Paths to scan
1015
# This should comprise of the base Plugin PHP file, plus directories that contain Plugin PHP files
1116
paths:
@@ -25,11 +30,17 @@ parameters:
2530
scanFiles:
2631
- /wp/wp-config.php
2732

28-
# Should not need to edit anything below here
29-
# Rule Level: https://phpstan.org/user-guide/rule-levels
30-
level: 5
33+
# Don't report unmatched ignored errors on older PHP versions (7.2, 7.3)
34+
reportUnmatchedIgnoredErrors: false
3135

3236
# Ignore the following errors, as PHPStan and PHPStan for WordPress haven't registered symbols for them yet,
3337
# so they're false positives.
3438
ignoreErrors:
35-
- '#Call to an undefined method WC_Order_Item::get_product\(\).#'
39+
- '#unknown class WC_Session_Handler#'
40+
- '#unknown class WC_Order_Item#'
41+
- '#Call to an undefined method WC_Order_Item::get_product\(\).#'
42+
- '#No error to ignore is reported#'
43+
44+
# Should not need to edit anything below here
45+
# Rule Level: https://phpstan.org/user-guide/rule-levels
46+
level: 5

phpstan.neon.dist

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ includes:
66

77
# Parameters
88
parameters:
9+
# Analyse against the minimum supported PHP version.
10+
# This flags features (union types, enums, str_contains, etc.) that would
11+
# fail on older PHP versions regardless of which PHP version PHPStan runs on.
12+
phpVersion: 70100
13+
914
# Paths to scan
1015
# This should comprise of the base Plugin PHP file, plus directories that contain Plugin PHP files
1116
paths:
@@ -25,11 +30,17 @@ parameters:
2530
scanFiles:
2631
- /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress/wp-config.php
2732

28-
# Should not need to edit anything below here
29-
# Rule Level: https://phpstan.org/user-guide/rule-levels
30-
level: 5
33+
# Don't report unmatched ignored errors on older PHP versions (7.2, 7.3)
34+
reportUnmatchedIgnoredErrors: false
3135

3236
# Ignore the following errors, as PHPStan and PHPStan for WordPress haven't registered symbols for them yet,
3337
# so they're false positives.
3438
ignoreErrors:
35-
- '#Call to an undefined method WC_Order_Item::get_product\(\).#'
39+
- '#unknown class WC_Session_Handler#'
40+
- '#unknown class WC_Order_Item#'
41+
- '#Call to an undefined method WC_Order_Item::get_product\(\).#'
42+
- '#No error to ignore is reported#'
43+
44+
# Should not need to edit anything below here
45+
# Rule Level: https://phpstan.org/user-guide/rule-levels
46+
level: 5

phpstan.neon.example

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ includes:
66

77
# Parameters
88
parameters:
9+
# Analyse against the minimum supported PHP version.
10+
# This flags features (union types, enums, str_contains, etc.) that would
11+
# fail on older PHP versions regardless of which PHP version PHPStan runs on.
12+
phpVersion: 70100
13+
914
# Paths to scan
1015
# This should comprise of the base Plugin PHP file, plus directories that contain Plugin PHP files
1116
paths:
@@ -25,11 +30,17 @@ parameters:
2530
scanFiles:
2631
- /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress/wp-config.php
2732

28-
# Should not need to edit anything below here
29-
# Rule Level: https://phpstan.org/user-guide/rule-levels
30-
level: 5
33+
# Don't report unmatched ignored errors on older PHP versions (7.2, 7.3)
34+
reportUnmatchedIgnoredErrors: false
3135

3236
# Ignore the following errors, as PHPStan and PHPStan for WordPress haven't registered symbols for them yet,
3337
# so they're false positives.
3438
ignoreErrors:
35-
- '#Call to an undefined method WC_Order_Item::get_product\(\).#'
39+
- '#unknown class WC_Session_Handler#'
40+
- '#unknown class WC_Order_Item#'
41+
- '#Call to an undefined method WC_Order_Item::get_product\(\).#'
42+
- '#No error to ignore is reported#'
43+
44+
# Should not need to edit anything below here
45+
# Rule Level: https://phpstan.org/user-guide/rule-levels
46+
level: 5

0 commit comments

Comments
 (0)