vim-php-refactoring-toolbox icon indicating copy to clipboard operation
vim-php-refactoring-toolbox copied to clipboard

Extract method (em) not work on static method

Open alquerci opened this issue 3 years ago • 0 comments

Hi,

Firstly, thanks for this great Vim plugin.

Be curious regarding issue #31

Note: I personally never used extract method on static method.


Before

    public static function testExtractMethodOnStatic($message)
    {   
        // Make a very cool wave with the message
        for ($i = 0; $i < strlen($message); $i++) {
            $message[$i] = $i % 2 ? strtoupper($message[$i]) : strtolower($message[$i]);
        }
    }

After

    public static function testExtractMethodOnStatic($message)
    {
        // Make a very cool wave with the message
        $message = $this->makeWaveWithMessage($message);
    }

    private function makeWaveWithMessage($message)
    {
        for ($i = 0; $i < strlen($message); $i++) {
            $message[$i] = $i % 2 ? strtoupper($message[$i]) : strtolower($message[$i]);
        }
        return $message;
    }

Expected

    public static function testExtractMethodOnStatic($message)
    {   
        // Make a very cool wave with the message
        $message = self::makeWaveWithMessage($message);
    }

    private static function makeWaveWithMessage($message)
    {   
        for ($i = 0; $i < strlen($message); $i++) {
            $message[$i] = $i % 2 ? strtoupper($message[$i]) : strtolower($message[$i]);
        }
        return $message;
    }

alquerci avatar Sep 27 '22 23:09 alquerci