PhpStorm 7.1.0 Web Help

PhpStorm provides the following inline refactorings:

  • The Inline Variable refactoring replaces redundant variable usage with its initializer. This refactoring is opposite to Extract Variable.
  • The Inline Function/Method refactoring results in placing the method's or function's body into the body of its caller(s); the method or function is deleted. This refactoring is opposite Extract Method.

Inline variable

Php example

Before After
                            public function getFeedObject($title, $description)
                            {
                            global $wgSitename, $wgContLanguageCode, $wgFeedClasses, $wgTitle;
                            $feedTitle = "$wgSitename - {$title} [$wgContLanguageCode]";
                            if (!isset($wgFeedClasses[$this->format]))
                            return false;
                            return new $wgFeedClasses[$this->format]
                            ($feedTitle, htmlspecialchars());
                            }
                        
                            public function getFeedObject($title, $description)
                            {
                            global $wgSitename, $wgContLanguageCode, $wgFeedClasses, $wgTitle;
                            if (!isset($wgFeedClasses[$this->format]))
                            return false;
                            return new $wgFeedClasses[$this->format]
                            ("$wgSitename - {$title} [$wgContLanguageCode]", htmlspecialchars());
                            }
                        

JavaScript example

Before After
                  Parenizor.method('toString', function ()
   {
        var string = '(' + this.getValue() + ')';
        return string;
    }
                            
                  Parenizor.method('toString', function ()
    {
        return '(' + this.getValue() + ')';
    }
                            

Inline method or function

Before After
                  function sum(a, b){
    return a + b;
}

function multiplication(a, b){
    c = sum(a, b);
    d = c * c;
    return d;
}

function division(a, b){
    result = sum(a, b) / multiplication(a, b);
    return result;
}
                            
                  function multiplication(a, b){
    c = a + b;
    d = c * c;
    return d;
}

function division(a, b){
    result = a + b / multiplication(a, b);
    return result;
}
                            
To perform the inline refactoring
  1. Place the caret in the editor at the desired symbol to be inlined.
  2. Do one of the following:
    • On the main menu or on the context menu of the selection, choose Refactor | Inline.
    • Press Ctrl+Alt+NCtrl+Alt+NCtrl+Alt+NCtrl+Alt+NCtrl+Alt+NCtrl+Alt+NCtrl+Alt+NShift+Alt+IAlt Command NAlt Command NAlt Command I.
  3. In the Inline dialog box that corresponds to the selected symbol, confirm the inline refactoring.

See Also

Procedures:

Web Resources: