Skip to content

Commit b2f1e21

Browse files
authored
Merge pull request #1180 from cloudinary/chore/phpstan-setup
Add PHPStan static analysis at level 0
2 parents d43c955 + f6b8ef3 commit b2f1e21

33 files changed

Lines changed: 651 additions & 215 deletions

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,41 @@ jobs:
4343
- name: Run build
4444
run: npm run build
4545

46+
phpstan:
47+
name: PHPStan
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v4
52+
53+
- name: Setup PHP
54+
uses: shivammathur/setup-php@v2
55+
with:
56+
php-version: '8.3'
57+
58+
- name: Cache Composer
59+
uses: actions/cache@v4
60+
with:
61+
path: ~/.composer/cache
62+
key: ${{ runner.os }}-composer-phpstan-${{ hashFiles('**/composer.lock') }}
63+
restore-keys: |
64+
${{ runner.os }}-composer-phpstan-
65+
66+
- name: Install Composer dependencies
67+
run: composer install --no-interaction --no-progress
68+
69+
- name: Cache PHPStan result cache
70+
uses: actions/cache@v4
71+
with:
72+
path: .phpstan-cache
73+
key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock', 'phpstan.neon.dist') }}-${{ github.sha }}
74+
restore-keys: |
75+
${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock', 'phpstan.neon.dist') }}-
76+
${{ runner.os }}-phpstan-
77+
78+
- name: Run PHPStan
79+
run: composer phpstan
80+
4681
e2e:
4782
name: E2E (Playwright)
4883
runs-on: ubuntu-latest

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ package/dist
5858

5959
# AI generated files
6060
.claude/
61+
62+
# PHPStan result cache
63+
/.phpstan-cache/

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
"phpcompatibility/phpcompatibility-wp": "dev-master",
1212
"phpcompatibility/php-compatibility": "dev-develop as 9.99.99",
1313
"automattic/vipwpcs": "^3.0",
14-
"wp-coding-standards/wpcs": "^3.0"
14+
"wp-coding-standards/wpcs": "^3.0",
15+
"phpstan/phpstan": "^2.0",
16+
"szepeviktor/phpstan-wordpress": "^2.0",
17+
"php-stubs/wp-cli-stubs": "^2.10",
18+
"php-stubs/woocommerce-stubs": "^9.0"
1519
},
1620
"config": {
1721
"platform": {
@@ -27,6 +31,9 @@
2731
],
2832
"fix": [
2933
"phpcbf"
34+
],
35+
"phpstan": [
36+
"phpstan analyse --memory-limit=-1"
3037
]
3138
},
3239
"minimum-stability": "dev"

composer.lock

Lines changed: 275 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)