Skip to content

Incorrect behavior of LocallyCalledStaticMethodToNonStaticRector #7992

@toastedghost

Description

@toastedghost

Bug Report

Subject Details
Rector version 0.17.1, last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/a94fe4b3-0e91-4aa2-b298-4ec49c34b32f

<?php

final class DemoFile
{
    public function run(string $var): bool
    {
        $checkRes = self::check($var);
        
        return $checkRes;
    }
    
    private static function check($value): bool
    {
        return true;
    }
}

Responsible rules

  • LocallyCalledStaticMethodToNonStaticRector

Actual Behavior

public function run(string $var): bool
     {
-        $checkRes = self::check($var);
+        $checkRes = $this->check();
         
         return $checkRes;
     }
     
-    private static function check($value): bool
+    private function check($value): bool
     {
         return true;
     }

Expected Behavior

public function run(string $var): bool
     {
-        $checkRes = self::check($var);
+        $checkRes = $this->check($var);
         
         return $checkRes;
     }
     
-    private static function check($value): bool
+    private function check($value): bool
     {
         return true;
     }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions