Adding USE statement automatically

I know there is a way to add use statement when cursor is positioned over unrecognized class name and I hit Alt+Enter. However if I already have inline FQCN, for example:

class OtherChoiceField extends \Symfony\Component\Form\AbstractType{

full path is added automatically from drop-down import list. Is there a way to optimize this code and create new use statement with \Symfony\Component\Form\AbstractType? It is kinda annoying to have FQCN all over the code :-/

Thanks!

4 comments
Comment actions Permalink

Hi Jovan,

Settings | Editor | Auto Import --> PHP | Automatically add 'use' statements
The above will do it automatically

0
Comment actions Permalink

Thanks you so much. :) My work is much simplier now!

I wasn't aware that this checkbox was added. I assume this came with version 5, since it wasn't there in 4.0.3 :)

0
Comment actions Permalink

Oh this feature does not work within PHPDoc. Instead, it leaves only class name which is, without proper use statement, undefined...

0
Comment actions Permalink

Hi Jovan,

Cannot help here -- I'm not really using namespaces myself and do not know how it actually works in PhpStorm.

I suggest checking the Issue Tracker for existing tickets and if none found feel free to submit new one.

0

Please sign in to leave a comment.