Skip to content

PrivatizeFinalClassPropertyRector cause invalid change on protected final modifier #9908

Description

@samsonasik

Bug Report

Subject Details
Rector version e.g. dev-main (invoke vendor/bin/rector --version)

Minimal PHP Code Causing Issue

Reproduced on PHP 8.4:

https://getrector.com/demo/b1c3546d-96ff-43c0-8182-c58093d6ddb1

Given the following code:

final class DemoFile
{
    protected final $x = true;
}

which valid on PHP 8.4 https://3v4l.org/gXaQt#v8.4.25

changed to:

 final class DemoFile
 {
-    protected final $x = true;
+    final private $x = true;
 }

and cause error:

Fatal error: Property cannot be both final and private

Ref https://3v4l.org/lhT8c#v8.4.25

Expected Behaviour

The final should be removed on private modifier, so should be:

 final class DemoFile
 {
-    protected final $x = true;
+    private $x = true;
 }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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