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

Extract Method does not work as others refactory tools

Open lockland opened this issue 8 years ago • 0 comments

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;
    }
}

lockland avatar Jun 21 '17 12:06 lockland