Reputation: 758
I have a class that has two methods that are used often:self::foo()
and self::bar()
.
I would like to surround text, mainly variables in other methods. I can do comments, if/else
, try/catch
, etc, but I can't with arbitrary method calls.
I don't even know if PHPStorm does this, honestly. Does anyone know how to do this?
UPDATE
I would like to take this:
function func() {
return $variable;
}
and make it this:
function func() {
return self::foo($variable);
}
or
function func() {
return this->bar($variable);
}
Upvotes: 0
Views: 46
Reputation: 165511
You can create and use Live Template that will do what you want (surround current selection with predefined template): separate template for each method call.
http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program -- the last section "Creating Surround Templates" is what you need in particular.
Upvotes: 2
Reputation: 42530
You can extract a function using WebStorm's refactoring tools.
Do do so, mark the code you want to have extracted and press Ctrl + Alt + M.
For more info, have a look at JetBrains' Website: http://blog.jetbrains.com/webide/2011/05/extract-function-method-refactoring-for-php/
Edit: Thanks for the clarification. I am not aware of a refactoring tool that fulfills this particular need. However, if you have a lot of occurrences in one file, Search and Replace might be helpful.
Upvotes: 1