Skip to content

[DeadCode] Add RemoveUnusedPublicMethodParameterRector#5925

Merged
TomasVotruba merged 2 commits intomainfrom
remove-unused-publci
May 30, 2024
Merged

[DeadCode] Add RemoveUnusedPublicMethodParameterRector#5925
TomasVotruba merged 2 commits intomainfrom
remove-unused-publci

Conversation

@samsonasik
Copy link
Copy Markdown
Member

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

@samsonasik
Copy link
Copy Markdown
Member Author

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

@TomasVotruba
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

I see, lets ship this then :)

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