Features Releases

Refactorings, Intentions & Quick-Fixes in PhpStorm 2019.1

Every PhpStorm release comes with lots of new refactorings, intentions, and quick-fixes, and PhpStorm 2019.1 is no exception.

In this release, we’ve enhanced the string juggling toolbox and made moving functions between files and classes easier. We’ve also added the new Method may be ‘static’ quick-fix, and provided a quick-fix for the Remove Unused Variable inspection.

Let’s look at these new features in more detail.

String Juggling Toolbox

When you work with string literals, tasks like joining or splitting a literal, even if small and simple, become tiresome sooner or later. To speed them up, we added some cool manipulation actions in a previous version, and we’ve just added a few more in this release.

To use any of these manipulation actions, simply press Alt+Enter on a string, and then choose what you’d like to do:

  • Convert interpolation to a sprintf call, or vice versa:Convert interpolation to sprintf
  • Convert a concatenated string to a sprintf:
    Convert concatenation to sprintf
  • Simply copy a concatenated string to clipboard to use it elsewhere:
    Copy concatenated string

Move To Class refactoring

When dealing with legacy apps, you’ll often find a file with a bunch of functions inside. You may decide to reorganize it a bit and move the functions to respective classes, which would also require finding and modifying all their usages.

With PhpStorm 2019.1, you don’t have to do this tedious task manually anymore. You can simply position the caret at the function, press Ctrl+T (Shift+Ctrl+Alt+T on Windows/Linux) and select Move… If your file contains several functions you’d like to move, open the Structure tool window (or the Structure View popup), select them there, and move them by using the same technique.

Move functions to class

‘Remove unused variable’ quick-fix

PhpStorm has had the Unused variable inspection for quite a long time, but provided no straightforward way to remove the variable. PhpStorm 2019.1 introduces a new quick-fix that does just that: it helps you get rid of the unused variables that appear in assignments and closures’ use lists.

unused_variable

The quick-fix is smart enough to detect situations when the assignment expression may have side effects. In such cases, it will suggest leaving the right-hand side as it is.

Method may be ‘static’ quick-fix

If a class has a method that doesn’t use any instance references, PhpStorm will give you a quick-fix to make this method static. Press Alt+Enter on such a method, and choose to make it static. All the method’s usages will be updated accordingly.

Make method static

We hope that these new features will save you from many mundane, routine tasks and help you focus on what’s truly important instead.

Your JetBrains PhpStorm Team
The Drive to Develop

image description