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 basic PHPStan linter #638

Merged
merged 6 commits into from
Sep 19, 2024
Merged

Add basic PHPStan linter #638

merged 6 commits into from
Sep 19, 2024

Conversation

kasparsd
Copy link
Collaborator

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 and package.json.

Testing Instructions

  1. Install composer dependencies via composer install after checking out this branch.
  2. Run composer lint-phpstan and confirm that [OK] No errors is returned.

Screenshots or screencast

Changelog Entry

Development: Introduce PHPstan tooling for development.

@@ -5,3 +5,4 @@
/dist/
/tests/logs/
.phpunit.result.cache
phpstan.neon
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow local overrides.

class-two-factor-core.php Show resolved Hide resolved
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",
Copy link
Collaborator Author

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.

@kasparsd kasparsd requested a review from dd32 September 18, 2024 15:16
@kasparsd kasparsd self-assigned this Sep 18, 2024
Copy link
Member

@dd32 dd32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kasparsd kasparsd merged commit 3f41808 into master Sep 19, 2024
48 checks passed
@kasparsd kasparsd deleted the 618-add-phpstan branch September 19, 2024 07:20
@kasparsd kasparsd mentioned this pull request Sep 19, 2024
@jeffpaul jeffpaul added this to the 0.10.0 milestone Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please use PHPStan
4 participants