Skip to content

MakeInheritedMethodVisibilitySameAsParentRector incorrect behaviour when direct parent is less restrictive than grand parent class #8880

@wernerkrauss

Description

@wernerkrauss

Bug Report

Subject Details
Rector version 1.2.8
PHP 8.3

Minimal PHP Code Causing Issue

class A //Framework
{
    protected function Foo() {}
}

class B extends A // in a module
{
    public function Foo() {}
}

class C extends B // my project specific code
{
    public function Foo() {}
}

Rector changes class C's method Foo to protected (as in class A) which causes a

PHP Fatal error: Access level to C::Foo() must be public (as in class B)

Expected Behaviour

Rector should set on the least restrictive acces level of all parent classes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions