New refactorings in PhpStorm 2018.3
Every PhpStorm release comes with new and enhanced refactorings, saving you from having to perform tedious manual tasks and making it easier for you to maintain your code.
PhpStorm 2018.3 is no exception. In this release, we are introducing the Replace with Alias, Inline Alias, and Сhange Class Member Visibility refactorings, as well as some tweaks to enhance some of our existing refactorings.
Let’s take a look at them in more detail.
Replace with Alias refactoring
With the new Replace with Alias refactoring, you can replace the import class statements such as
use Foo\Bar with ones referring to a class alias, for example,
use Foo\Bar as Baz. The refactoring will also replace all
Bar usages with
You can apply this refactoring from a class usage, too.
In PhpStorm 2018.3, aliases are displayed in italics both in unqualified and fully qualified class names, so it has become much easier to distinguish them from regular classes. If necessary, you can customize their appearance under Settings / Preferences | Editor | Color Scheme | PHP:
Inline Alias refactoring
The Inline Alias refactoring is opposite to the above one: it lets you inline a redundant alias and update the corresponding usages accordingly.
Just like replacing with an alias, the refactoring works in both use statements and occurrences.
Сhange Class Member Visibility refactoring
The new Сhange Class Member Visibility refactoring lets you change the visibility of a class member, be it a property or a method. PhpStorm will analyze the class member usages and make sure that the visibility change does not introduce any bugs.
If there are any issues found, PhpStorm will display the conflicts in the Find tool window and prompt you to take an action.
Rename refactoring for private fields
In earlier versions of PhpStorm, when you renamed the private properties of a class using the Rename refactoring, it would search through the entire project, which was not optimal performance-wise. PhpStorm 2018.3 will, by default, search through context usages, and so performance is much better for this refactoring.
In some cases, searching through the entire project is still required. For example, if you use a
property_exists() or similar function, you can access the private class property from outside the scope. To handle this, simply enable the new Search in global scope option in the Rename dialog when performing a refactoring. The usages will be detected so that you can rename them, too.
Extract method refactoring
The Extract method refactoring has been given a useful enhancement. In PhpStorm 2018.3, it will now properly infer the parameters’ data types based on the type of the source variables.
Let us know what you think, and stay tuned for more updates!
Your JetBrains PhpStorm Team
The Drive to Develop
Subscribe to Blog updates
Thanks, we've got you!
Qodana Clone Finder: Early Access Program
In December 2020, we announced the EAP for Qodana, which is rapidly evolving into a comprehensive platform that allows companies to perform multi-level evaluations of the quality of code they own, contract, or purchase. Qodana helps you detect bugs without relying on an IDE, either on a local machi…
PhpStorm 2020.2 EAP #3
The Early Access Program for PhpStorm 2020.2 is in full swing and today we’ve got the third build of the 2020.2 EAP for you. In this blog post, you can read about improvements for Git installed in WSL2 and Search Everywhere. Download PhpStorm 2020.2 EAP (more…)…
PhpStorm 2019.3.3 Preview
We’ve just rolled out a preview for the third minor update for PhpStorm 2019.3. Please give the PhpStorm 2019.3.3 Preview build 193.6494.5 a try and share your feedback with us. (more…)…
How to Upgrade to PHP 7.4 with PhpStorm
Check out our fresh video with a few nice tips and tricks on how to update your codebase to PHP 7.4. It combines materials from the PhpStorm 2019.2 and PhpStorm 2019.3 releases, with a few cool bonuses to boot. Nikita drew our attention to the fact that setters are slower than assigning prop…