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
sprintfcall, or vice versa:
- Convert a concatenated string to a
- Simply copy a concatenated string to clipboard to use it elsewhere:
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.
‘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.
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.
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
Subscribe to Blog updates
PhpStorm 2023.3 Is Now Available
Explore the new features in PhpStorm 2023.3: support for PHP 8.3, the Pest test framework, improvements for Symfony projects and AI Assistant.
PhpStorm Now Supports PHP 8.3
PhpStorm now provides full support for PHP 8.3 feature: the new `#[Override]` attribute and `json_validate()` function, and more!