Skip to content

private constant usage via $this:: not detected (false positive) #9186

@fbuchlak

Description

@fbuchlak

Bug Report

Subject Details
Rector version 2.0.16

RemoveUnusedPrivateClassConstantRector rule has false positives

Minimal PHP Code Causing Issue

<?php declare(strict_types=1);

final readonly class Test
{
    private const string SOME_CONST = '1';

    public function hello(): string
    {
        return $this::SOME_CONST;
    }
}

becomes

 final readonly class Test
 {
-    private const string SOME_CONST = '1';
-
     public function hello(): string
     {
         return $this::SOME_CONST;

Applied rules:

  • RemoveUnusedPrivateClassConstantRector

Expected Behaviour

Should be skipped by this rule

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