auto-import is using sub namespace

Hi,

I have a problem with phpstorm auto imports and classname completions, sometime he is not using import statement and prepends a part of the namespace to the autocmpleted classname.

 

To demonstrate it let's say I have the following classes in my project:

 

<?php

namespace Foo;

class Bar {}

 

<?php

namespace Foo\Bar;

class Baz {}

Now here is a file I'm writing code in:

<?php

use Foo\Bar;

$bar = new Bar();

$baz = new Ba{cursor is here and using autocomplete to have 'Baz'};

After I autocomplete, I get 'new Bar\Baz()'. When I wanted 'new Baz()'. Is ther a way to configure this feature? 

That feature already proved to be very harmful for me, because if I use the phpstorm refactor  tool to rename class '\Foo\Bar' then the use statement for Foo\Bar is also renamed, and Bar\Baz cannot be resolved anymore and leads to class not found error.s 

Thanks

0

As far as I can see this cannot be controlled yet. Please vote for corresponding feature request: https://youtrack.jetbrains.com/issue/WI-30663

1

请先登录再写评论。