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

[Php83] Allow indirect override abstract method on Grand Child on AddOverrideAttributeToOverriddenMethodsRector #6512

Merged
merged 6 commits into from
Nov 26, 2024

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Nov 26, 2024

continue of patch:

abstract method override can be layered children override, so indirect override should be be make sense to override.

see https://getrector.com/demo/45456834-d91c-4036-aa63-3d920562498d

the GrandChild class should be allowed have make sense to have #[\Override]

@samsonasik samsonasik changed the title [Php83] Allow indirect override abstract method on AddOverrideAttributeToOverriddenMethodsRector [Php83] Allow indirect override abstract method on Grand Child on AddOverrideAttributeToOverriddenMethodsRector Nov 26, 2024
@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I am merging it ;)

/cc @PhilETaylor please test this in case of regression for this change. This basically allow add #[\Override] on indirect override abstract method, eg:

abstract class SomeAbstractClass
{
    public function run();
}

class SomeChild extends SomeAbstractClass
{
    public function run()
    {
    	echo 'default';
    }
}


class GrandChild extends SomeChild
{
+   #[\Override]
    public function run()
    {
    	echo 'override default';
    }
}

The GrandChild should have added #[\Override] as override non-empty method from its parent class. The first override from abstract method doesn't have #[\Override], but the child need have as parent have content, and it override it.

@samsonasik samsonasik merged commit 3511ca1 into main Nov 26, 2024
36 checks passed
@samsonasik samsonasik deleted the allow-indirect branch November 26, 2024 05:52
@PhilETaylor
Copy link
Contributor

  - Downloading rector/rector (dev-main 9e165cc)
  - Upgrading rector/rector (dev-main 87ea771 => dev-main 9e165cc): Extracting archive

Ran my cleanup and nothing changed, so no regression on my specific code like there was last week. However, my issue last week was with a class using a trait, and some methods in that class were incorrectly getting the Override attribute for some methods. You fixed that last week.

On my main project I run bleeding edge dev-main rector, update composer deps daily, and run cleanup (ecs, rector etc) daily, but when things go wrong I dont ask for support but if I can replicate I like to report bugs.

@samsonasik
Copy link
Member Author

Thank you for verify 👍

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