Skip to content

Incorrect behavior of VariableConstFetchToClassConstFetchRector #9663

@dczech

Description

@dczech

Bug Report

Subject Details
Rector version 2.3.7
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/9ae08865-9653-46a8-a145-5a0be3b7078c

<?php

interface WithConstInterface {
    public const NAME='undefined';
}

class Option1 implements WithConstInterface {
    public const NAME='OPTION-1';
}

class Option2 implements WithConstInterface {
    public const NAME='OPTION-2';
}

final class OptionProcessor {
    public function run(WithConstInterface $option): string
    {
        return $option::NAME;
    }
}

Responsible rules

  • VariableConstFetchToClassConstFetchRector

Expected Behavior

// no change

Rector should not update constants which are not declared final.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions