Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract method (em) not work on static method #37

Open
alquerci opened this issue Sep 27, 2022 · 0 comments
Open

Extract method (em) not work on static method #37

alquerci opened this issue Sep 27, 2022 · 0 comments

Comments

@alquerci
Copy link

alquerci commented Sep 27, 2022

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;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant