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

Inconsistent class hierarchy refactoring with OptionalParametersAfterRequiredRector #8322

Closed
eduard-sukharev opened this issue Nov 21, 2023 · 2 comments
Labels

Comments

@eduard-sukharev
Copy link

eduard-sukharev commented Nov 21, 2023

Bug Report

Subject Details
Rector version v0.18.10

When rector encounters hierarchy of classes where child class redefines a method to receive one of the parameters as optional (which obviously a bad idea and a rather pungent code smell, but still), it makes the optional parameter last in the child class, but keeps sibling classes and parent class intact, which leads to fatal error.

Minimal PHP Code Causing Issue

https://getrector.com/demo/96afac7f-bd7f-4809-b1dd-5fed5038fa8d

Here's a demo repository to showcase the issue.

Expected Behaviour

Rector should either change the complete code hierarchy, skip the change (with warning), or make the optional parameter non-optional (with warning)

@samsonasik
Copy link
Member

I think the solution is to remove default parameter value when it is before required field, and parent param doesn't have default value.

@TomasVotruba
Copy link
Member

Closing as stale to avoid piling possible solved issue. Thanks for understanding 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants