Importing Improvements in PhpStorm 2017.1
PhpStorm 2017.1 brings some improvements to the auto-importing of namespaced constructs during your coding; let’s take a look at them.
When you’re using code completion to pick a globally namespaced class, function, or constant, previously PhpStorm would have prefixed the namespace with a `\\` to indicate it was global. In PhpStorm 2017.1, however, you have the option to automatically add these constructs to the imported constructs using the `use` keyword. This is particularly useful if you are writing legacy code from pre-PHP 5.3 which is not namespaced. You can turn this setting on using the Editor | General | Auto Import | PHP | Enable auto-import from the global space option.
This has the added bonus of making your code slightly faster (as you can see from a blog post – Optimizing PHP performance by using fully-qualified function calls.
There have also been some general improvements around imports:
- We modified an existing setting to control whether fully qualified class names are used in DocBlock annotations, you can find it at Editor | Code Style | PHP | PHPDoc | Generated Doc Blocks | Use fully-qualified class names.
- Fixed some problems around finding usages and refactoring names that were imported as aliases.
- Provide more useful messages when imports are not needed, instead of showing a single generic message (for example, if an import is not needed because it’s already in the scope of the class, we now tell you that instead of showing a generic message).
- Improved auto-importing when namespaced and not in the scope of a class – this now works with functions and constants, not just other namespaced classes.
We hope this makes life easier for you, let us know what your think.
– Gary & The PhpStorm Team
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…