Skip to content

PublicConstantVisibilityRector not working on final constants #7812

@Fabrn

Description

@Fabrn

Bug Report

Subject Details
Rector version v0.15.19
Rector rule PublicConstantVisibilityRector

The issue

I was simply trying to run the PublicConstantVisibilityRector rule on the whole project. Seeing nothing was happening, I tried using it on a specific class. Here is the result :

Exemple of code :

class ExempleCommand extends Command
{
    const EXIT_OK = 0;
    final const EXIT_KO = 1;
    final const EXIT_NULL = 2;
}

Dry run from Rector :

---------- begin diff ----------
@@ @@
 {
-    const EXIT_OK = 0;
+    public const EXIT_OK = 0;
     final const EXIT_KO = 1;
     final const EXIT_FLUX_NULL = 2;
    ----------- end diff -----------

Expected Behaviour

For me, the excepted behavior is to add the public visibility between final and const, like such :

class ExempleCommand extends Command
{
    public const EXIT_OK = 0;
    final public const EXIT_KO = 1;
    final public const EXIT_NULL = 2;
}

I guess that's an issue since the FinalizePublicClassConstantRector rule adds the final keyword in front of constants defined as public such as the example above.

Thanks

Thank you guys for keeping up this great library. I really enjoy using it and honestly without it we would be struggling pretty hard 👍

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