-
-
Notifications
You must be signed in to change notification settings - Fork 452
rector: AddParamBasedOnParentClassMethodRector
#5040
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
base: main
Are you sure you want to change the base?
rector: AddParamBasedOnParentClassMethodRector
#5040
Conversation
sreichel
commented
Oct 27, 2025
- https://getrector.com/rule-detail/add-param-based-on-parent-class-method-rector
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 enables the AddParamBasedOnParentClassMethodRector Rector rule, which automatically adds missing parameters to child class methods based on their parent class method signatures. The changes update method signatures to match their parent classes and improve documentation consistency by replacing "none" return types with "void".
- Enabled
AddParamBasedOnParentClassMethodRectorin Rector configuration - Updated method signatures to match parent class signatures by adding missing parameters
- Standardized docblock return types from "none" to "void"
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
.rector.php |
Removed the skip rule for AddParamBasedOnParentClassMethodRector to enable the refactoring |
lib/Varien/Directory/Collection.php |
Updated method signatures (load, addFilter, toXml) to match parent class signatures and standardized docblock return types |
app/code/core/Mage/Core/Model/Mysql4/Design/Theme/Collection.php |
Added missing parameters to load() method to match parent class signature |
app/code/core/Mage/Adminhtml/Controller/Rss/Abstract.php |
Added default null value to _getHelper() parameter to match parent class signature |
| * @return void | ||
| */ | ||
| public function toXml(&$xml, $recursionLevel = 0, $addOpenTag = true, $rootName = 'Struct') | ||
| public function toXml(&$xml = null, $recursionLevel = 0, $addOpenTag = true, $rootName = 'Struct') |
Copilot
AI
Oct 27, 2025
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.
The &$xml parameter should not have a default value of null when passed by reference. The method initializes $xml = '' at line 358 when $recursionLevel == 0, but the reference parameter with a null default could cause issues when the method is called without arguments. Consider making $xml required or handling the null case explicitly before using it as a string reference.
| public function toXml(&$xml = null, $recursionLevel = 0, $addOpenTag = true, $rootName = 'Struct') | |
| public function toXml(&$xml, $recursionLevel = 0, $addOpenTag = true, $rootName = 'Struct') |
| } | ||
|
|
||
| /** | ||
| * add filter |
Copilot
AI
Oct 27, 2025
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.
The new $type parameter is not documented in the method's docblock. Add a @param tag to describe this parameter and its purpose, including the default value and expected values.
| * add filter | |
| * Add a filter to the collection. | |
| * | |
| * @param string $field The field to filter on. | |
| * @param mixed $value The value to filter by. | |
| * @param string $type Logical operator for the filter ('and' or 'or'). Default is 'and'. |
|


