Refactoring scope

Is it possible to refactor a variable with a method only?

For example:
I use the variable $return to return a value in more then one method.

When I select the variable within a method, press Shift-F6, rename the variable to $foo, the preview tells me it wants to change the $return variable to $foo throughout my entire project.

OS: Linux
PHPStorm: EAP PS-138.567.

Peter

5 comments
Comment actions Permalink

Hi there,

Could you please provide some simple file (or collection of files) that would reproduce this problem. I've tried this on this simple code and it seems to be workign just fine (and so far have NEVER faced such issue myself):

class One {

     public $meow = '';
     
     public function someMethod()
     {
          $return = '1234';
     }
     
     public function someMethod2()
     {
          $return = '1234';
     }
}


But before that -- please try "File | Invalidate Caches..." and restart IDE

0
Comment actions Permalink

The invalidate Caches/restart seemed to have done the trick right now.

Thanks for the reply, if it comes up again I'll post an update.

0
Comment actions Permalink

Alright,

After working for a bit the refactoring in the scope stopped working again. Not sure why it happens, I only edit the files in PHPStorm.

Tried the Invalid Cache/Restart twice with no luck.

0
Comment actions Permalink

I got it now, if I check the boxes comments and text occurences, the refactor wants to change it in all non-php files.

0
Comment actions Permalink

Another mystery solved :)
 

0

Please sign in to leave a comment.