Skip to content

Conversation

@calebdw
Copy link
Contributor

@calebdw calebdw commented Sep 11, 2025

Hello!

Closes rectorphp/rector#9369

This fixes cases where an empty constructor isn't removed even when the parent does not have a constructor.

It turns out that the removed if statement is not needed, the previous conditions already prevent overridden methods from being removed.

Thanks!

Copy link
Member

@samsonasik samsonasik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, let's give it a try, thank you @calebdw

@samsonasik samsonasik merged commit e00f52f into rectorphp:main Sep 11, 2025
49 checks passed
@calebdw calebdw deleted the calebdw/push-ontqsxuxwurx branch September 11, 2025 04:08
@samsonasik
Copy link
Member

I see for trait use why already checked, there is IsClassMethodUsedAnalyzer::isClassMethodUsed() that check on trait already :)

@samsonasik
Copy link
Member

Oh, it seems private empty __construct should be skipped as used on purpose to avoid instantiation

@samsonasik
Copy link
Member

Ok, there is fixture for that already

final class KeepPrivateConstructor
{
private function __construct()
{
}

that checked on ClassMethodManipulator::isNamedConstructor()

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.

Incorrect behaviour of RemoveEmptyClassMethodRector

2 participants