Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a PHPStan configuration and run it as a GitHub Action #808

Merged
merged 7 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading