Skip to content

Commit

Permalink
Merge pull request #808 from 10up/feature/phpstan
Browse files Browse the repository at this point in the history
Add a PHPStan configuration and run it as a GitHub Action
  • Loading branch information
iamdharmesh authored Sep 27, 2024
2 parents c1da04f + e8c14ff commit 26e2a30
Show file tree
Hide file tree
Showing 33 changed files with 626 additions and 63 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ LICENSE.md export-ignore
package-lock.json export-ignore
package.json export-ignore
phpcs.xml.dist export-ignore
phpstan.neon.dist export-ignore
phpunit.xml.dist export-ignore
README.md export-ignore
webpack.config.js export-ignore
10 changes: 5 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup node v16 and npm cache
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm

- name: Install Node dependencies
- name: Install node dependencies
run: npm ci --no-optional

- name: Get updated JS files
id: changed-files
uses: tj-actions/changed-files@v42
uses: tj-actions/changed-files@v45
with:
files: |
**/*.js
Expand All @@ -54,7 +54,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set standard 10up cache directories
- name: Set standard cache directories
run: |
composer config -g cache-dir "${{ env.COMPOSER_CACHE }}"
Expand All @@ -78,7 +78,7 @@ jobs:

- name: Get updated PHP files
id: changed-files
uses: tj-actions/changed-files@v42
uses: tj-actions/changed-files@v45
with:
files: |
**/*.php
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: PHPStan

on:
push:
branches:
- develop
- trunk
pull_request:
branches:
- develop

jobs:

phpstan:
name: PHPStan
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: composer:v2

- name: Install dependencies
run: composer install

- name: PHPStan
run: composer phpstan
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,24 @@
},
"require-dev": {
"10up/phpcs-composer": "^3.0",
"yoast/phpunit-polyfills": "^1.0.0"
"yoast/phpunit-polyfills": "^1.0.0",
"szepeviktor/phpstan-wordpress": "dev-master",
"phpstan/extension-installer": "1.4.x-dev",
"php-stubs/wp-cli-stubs": "dev-master",
"johnbillion/wp-compat": "dev-trunk",
"phpstan/phpstan-deprecation-rules": "1.2.x-dev"
},
"scripts": {
"lint": "phpcs -s . --runtime-set testVersion 7.4-",
"lint-fix": "phpcbf .",
"phpstan": "phpstan analyse --memory-limit=2048M -v",
"pre-autoload-dump": "Aws\\Script\\Composer\\Composer::removeUnusedServices"
},
"minimum-stability": "dev",
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
},
"archive": {
Expand Down
Loading

0 comments on commit 26e2a30

Please sign in to comment.