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 does not work as others refactory tools #28

Open
lockland opened this issue Jun 21, 2017 · 0 comments
Open

Extract Method does not work as others refactory tools #28

lockland opened this issue Jun 21, 2017 · 0 comments

Comments

@lockland
Copy link

lockland commented Jun 21, 2017

When I execute a ExtractMethod, it extract only the code I have selected but does not replace others occurrences of the snippet code by the same structure of the selected code.

Environment Info:
Distro CentOS 6.9
PHP 5.3.3
VIM 7.4.629

Example:

Code before execute Extract Method

<?php

class Foo
{
    function doSomething()
    {
        $csvData = 'name, lastname';
        $a = explode(",", $csvData);
        return $a;
    }

    function doAnotherSomething()
    {
        $csvData = 'name, lastname';
        $a = explode(",", $csvData);
        //Do more things
        return $a;
    }
}

Code after execute Extract Method

<?php

class Foo
{
    function doSomething()
    {
        $csvData = 'name, lastname';
        $a = $this->explodeMe($csvData);
        return $a;
    }

    private function explodeMe($csvData)
    {
        $a = explode(",", $csvData);
        return $a;
    }

    function doAnotherSomething()
    {
        $csvData = 'name, lastname';
        $a = explode(",", $csvData);
        //Do more things
        return $a;
    }
}

Expected Result

<?php

class Foo
{
    function doSomething()
    {
        $csvData = 'name, lastname';
        $a = $this->explodeMe($csvData);
        return $a;
    }

    private function explodeMe($csvData)
    {
        $a = explode(",", $csvData);
        return $a;
    }

    function doAnotherSomething()
    {
        $csvData = 'name, lastname';
        $a = $this->explodeMe($csvData);
        //Do more things
        return $a;
    }
}
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