Features Releases

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

image description