Skip to content

Extract Method does not work as others refactory tools #28

Open
@lockland

Description

@lockland

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions