#40 Unwrapping and Removing Statements

The inverse of tip #39 Surrounding Code with Language Constructs, PhpStorm can assist in removing language constructs that are surrounding a piece of code.

Place the cursor on the expression within the construct that you wish to unwrap or remove and press Cmd/Ctrl+Shift+Delete or navigate to Code | Unwrap/Remove… in the menus. A popup will appear listing all of the available actions based on the current context.

Hovering over one of the list items will allow you to preview the change it will apply, indicating which parts of the code will be removed and which parts will remain. Select the list item to apply the refactor to your code.

The Unwrap/Remove refactor can also be used on HTML tags!

Further Reading

comments powered by Disqus