Search code examples
phpstorm

PHPStorm - create variable of selected text


I remember It's possible to create variable from selected text in storm, but I cant find how to do this.

If I have code like this:

$a = new SomeClass(new A(), new B());

...and I select text

new B()

PHPStorm should change this code to:

$newVawiable = new B();
$a = new SomeClass(new A(), $newVariable);

I remember It's possible, but I don't remember how.


Solution

  • Refactor | Extract | Variable...

    Additional info/tutorial: https://confluence.jetbrains.com/display/PhpStorm/PHP+Code+Refactorings+in+PhpStorm