-
Notifications
You must be signed in to change notification settings - Fork 0
Implement TooManyMethods #93
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
Conversation
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.
Pull request overview
This PR implements the TooManyMethods rule, a PHPStan extension that detects classes, interfaces, traits, and enums with an excessive number of methods, helping identify code that violates the Single Responsibility Principle.
Key changes:
- Adds a new TooManyMethods rule with configurable method count threshold and pattern-based method filtering
- Provides comprehensive test coverage across multiple configuration scenarios
- Includes complete documentation and README integration
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Rules/TooManyMethods/TooManyMethodsRule.php | Main rule implementation analyzing ClassLike nodes and counting methods with optional pattern-based filtering |
| src/Rules/TooManyMethods/Config.php | Configuration class with max_methods threshold and ignore_pattern regex support |
| config/extension.neon | Schema definition, default parameters, and service registration for the rule |
| tests/Rules/TooManyMethods/TooManyMethodsRuleTest.php | Default configuration tests validating error reporting for classes, traits, interfaces, and enums |
| tests/Rules/TooManyMethods/NoIgnorePatternTest.php | Tests verifying all methods are counted when ignore_pattern is empty |
| tests/Rules/TooManyMethods/CustomMaxMethodsTest.php | Tests validating custom max_methods threshold behavior |
| tests/Rules/TooManyMethods/Fixture/ExampleClass.php | Test fixtures with various method counts and naming patterns |
| tests/Rules/TooManyMethods/config/*.neon | Test configuration files for different rule scenarios |
| docs/TooManyMethods.md | Complete rule documentation with configuration options and examples |
| README.md | Added TooManyMethods to the Design rules table |
| CLAUDE.md | AI coding instructions for the project (appears to be project documentation) |
| .gitignore | Added .claude/settings.local.json to ignore list |
Validates the ignore_pattern configuration by checking both preg_match return value and preg_last_error() to catch all potential regex errors, throwing InvalidArgumentException with a descriptive message when invalid.
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.
Pull request overview
Copilot reviewed 38 out of 39 changed files in this pull request and generated no new comments.
Closes #44