Skip to content

Conversation

@b-l-i-n-d
Copy link
Collaborator

@b-l-i-n-d b-l-i-n-d commented Jan 28, 2026

🚀 Summary
This PR integrates PHPStan into our development workflow using Husky and lint-staged. Staged PHP files will now be automatically analyzed for logic errors and type mismatches before they can be committed to the repository.

🛠 Key Changes

  • PHPStan Integration: Added phpstan, phpstan-wordpress, and the phpstan/extension-installer as development dependencies.
  • Pre-commit Automation: Configured .lintstagedrc to execute phpstan analyze on staged PHP files.
  • Resource Optimization: Included the --memory-limit=-1 flag in the pre-commit hook to prevent analysis failures on larger files or environments with restricted memory.
  • Tooling Support: Although we aren't enforcing them in the pre-commit hook yet, I've also included phpcs and wpcs (WordPress Coding Standards) as dev-dependencies so they can be run manually by the team.

📦 How to update your local environment
Please run the following in both tutor and tutor-pro directories to initialize the new tools:

composer install
npm install

✅ Benefits

  • Early Bug Detection: Catches potential issues like undefined variables, incorrect return types, and logic flaws before they reach the codebase.
  • Performance: By using lint-staged, we only analyze the files currently being changed, keeping the hook fast and efficient.

@b-l-i-n-d b-l-i-n-d requested a review from shewa12 January 28, 2026 04:27
@b-l-i-n-d b-l-i-n-d added the QoL Quality of Life label Jan 28, 2026
@b-l-i-n-d b-l-i-n-d changed the title ✨ Integrate PHPCS, PHPCBF, and PHPStan with Husky pre-commit hooks ✨ Add PHPStan static analysis to Husky pre-commit hooks Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

QoL Quality of Life

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants