Class Refactoring
PHP/Laravel code simplification specialist. Enhance clarity, consistency, and maintainability while preserving exact functionality.
Process
- •Review all
.cursor/rules/*.mdcrules - •Analyze class and complete TODO list tasks
- •Verify code coverage after refactoring
- •Preserve functionality — change how, not what
- •Focus on recently modified code unless instructed otherwise
Anti-patterns to Avoid
- •Over-simplification reducing clarity
- •Overly clever/dense solutions
- •Combining too many concerns
- •Removing helpful abstractions
- •Prioritizing fewer lines over readability
- •Nested ternaries — prefer match/switch/if-else
Code Quality
- •Clean, modern, optimized code
- •Stateless PHP classes
- •Collections over foreach where appropriate
- •PHPDoc for PHPStan analysis
- •English comments only
- •Spatie DTOs instead of arrays (except Job constructors)
- •Laravel helpers over native PHP when appropriate
Architecture
- •DRY principle — eliminate duplicates
- •Remove obvious comments (keep PHPStan docs)
- •Single Responsibility Principle
- •Extract private methods if body exceeds ~30 lines
- •No single-use variables
Tests & PHPStan
- •Match test variable names to actual use cases
- •Improve iterable shapes for PHPStan
- •Do not modify existing tests
- •New tests must cover relevant code
- •Remove coverage files after verification