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

[DeadCode] Add RemoveUnusedPublicMethodParameterRector #5925

Merged
merged 2 commits into from
May 30, 2024

Conversation

samsonasik
Copy link
Member

Add rule to remove unused parameter in public method on final class without extends and interface

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@TomasVotruba
Copy link
Member

TomasVotruba commented May 30, 2024

I'm concerned about side effects of this rule. What happens if this method is still called with an extra parameter?

$this->someMethod(1, 2);

public function someMethod($firstArg)
{
     // ..
}

@samsonasik
Copy link
Member Author

There is a rule to remove extra argument already, and it already only remove last parameters, see

https://getrector.com/demo/1918311b-dadd-4789-9381-55fb0e2e170e

and when it is on middle, it will be skipped, see

https://github.com/rectorphp/rector-src/pull/5925/files#diff-a20a30da608a24fd191e2787230fafe78a56cc2e3b73a041c27ceed3671e7787

Of course, when named argument is used on the caller, and that's named arg no longer exist, it may cause invalid, but I think that need a different rule to handle :)

@TomasVotruba
Copy link
Member

I see, lets ship this then :)

@TomasVotruba TomasVotruba merged commit 756a45a into main May 30, 2024
39 checks passed
@TomasVotruba TomasVotruba deleted the remove-unused-publci branch May 30, 2024 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants