-
Notifications
You must be signed in to change notification settings - Fork 153
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 basic PHPStan linter #638
Conversation
@@ -5,3 +5,4 @@ | |||
/dist/ | |||
/tests/logs/ | |||
.phpunit.result.cache | |||
phpstan.neon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow local overrides.
composer.json
Outdated
"wp-coding-standards/wpcs": "^3.1", | ||
"yoast/phpunit-polyfills": "^2.0" | ||
}, | ||
"scripts": { | ||
"lint": "phpcs", | ||
"lint-compat": "phpcs -p --standard=PHPCompatibilityWP --runtime-set testVersion 7.2- --extensions=php --ignore='tests/,dist/,includes/Yubico/,vendor/,node_modules/' .", | ||
"lint-phpstan": "phpstan analyse --memory-limit=1G", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running without bumping the memory limit can sometimes return passing checks when they actually didn't run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What?
Introduces phpstan with WordPress core stubs through szepeviktor/phpstan-wordpress.
Why?
Fixes #618.
Static analysis helps us uncover potential bugs and edge cases. Introducing the tooling didn't require a lot adjustments thanks to work already done in #619.
How?
Add the tooling as Composer development dependency and introduce additional lint scripts in
composer.json
andpackage.json
.Testing Instructions
composer install
after checking out this branch.composer lint-phpstan
and confirm that[OK] No errors
is returned.Screenshots or screencast
Changelog Entry
Development: Introduce PHPstan tooling for development.