Skip to content

Commit 5bde3d5

Browse files
dev: upgrade phpcs and add phpstan
- Upgrade PHPCS - Add PHPStan with LV 6 baseline - Fixed some issues reported by PHPCS and PHPStan Since there are numerous issues with PHPStan, a baseline has been added for the existing issues. When an old problem is solved, PHPStan will report it, and the baseline needs to be regenerated.
1 parent 621af35 commit 5bde3d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4347
-1522
lines changed

.distignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ docker-compose.travis.yml
4242
docker-compose.ci.yml
4343
.wp-env.json
4444
artifacts
45+
phpstan.neon
46+
phpstan-baseline.neon

.github/workflows/test-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- uses: actions/setup-node@v4
1515
with:
16-
node-version: "18"
16+
node-version: "20"
1717
cache: "npm"
1818
- name: Install npm deps
1919
run: |

.github/workflows/test-lint-js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Setup node
1818
uses: actions/setup-node@v4
1919
with:
20-
node-version: "18"
20+
node-version: "20"
2121
cache: "npm"
2222
- name: Install Dependencies
2323
run: npm install

.github/workflows/test-php.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ jobs:
2525
- name: Run PHPCS
2626
run: composer run lint
2727

28+
phpstan:
29+
name: PHPStan
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Setup PHP version
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: "7.4"
36+
extensions: simplexml
37+
- name: Checkout source code
38+
uses: actions/checkout@v4
39+
- name: Install composer
40+
run: |
41+
composer install --prefer-dist --no-progress
42+
- name: Run phpstan
43+
run: composer run phpstan
44+
2845
phpunit:
2946
name: PHPUnit
3047
runs-on: ubuntu-latest

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
"scripts": {
3232
"format": "phpcbf --standard=phpcs.xml --report-summary --report-source",
3333
"lint": "phpcs --standard=phpcs.xml",
34-
"test": "phpunit"
34+
"test": "phpunit",
35+
"phpstan": "phpstan",
36+
"phpstan:generate:baseline": "phpstan --generate-baseline"
3537
},
3638
"minimum-stability": "dev",
3739
"prefer-stable": true,
@@ -48,6 +50,9 @@
4850
"wp-coding-standards/wpcs": "^3.1",
4951
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
5052
"phpcompatibility/phpcompatibility-wp": "^2.1",
51-
"yoast/phpunit-polyfills": "^4.0"
53+
"yoast/phpunit-polyfills": "^4.0",
54+
"automattic/vipwpcs": "^3.0",
55+
"phpstan/phpstan": "^1.12",
56+
"szepeviktor/phpstan-wordpress": "^1.3"
5257
}
5358
}

0 commit comments

Comments
 (0)