Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Rename local variable only works within classes. #68

Open
LeighBicknell opened this issue May 27, 2015 · 2 comments
Open

Rename local variable only works within classes. #68

LeighBicknell opened this issue May 27, 2015 · 2 comments

Comments

@LeighBicknell
Copy link

I realise that this is designed primarily for use within classes however sometimes you can't/don't have 100% of your functions as methods in a class, when working in Wordpress for example.

Having the rename-local-variable functionality working for standard global space functions as well as methods would be a nice feature. Currently it returns an error:

$ php refactor.phar rename-local-variable test.php 136 oldname newname

[QafooLabs\Refactoring\Domain\Model\RefactoringException]  
  The range 136-136 is not inside one single method.         

rename-local-variable file line name new-name
@funivan
Copy link

funivan commented Oct 6, 2015

I think this is normal. How to detect if new variable name is already used?

@LeighBicknell
Copy link
Author

I'm sure the current functionality is normal, this is more a request for an extension of an existing feature than it is a bug report.

Maybe i'm missing something, which is quite likely because I haven't looked into the code base :*). But I don't immediately see any reason that changing the name of a local variable within a global space function is any more difficult than changing the name of a local variable within a class' method?

class MyClass
{
    private function MyClassFunction()
    {
        $my_var = 1;
        $my_var++;
    }
}

vs

function MyClassFunction()
{
    $my_var = 1;
    $my_var++;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants