How can I make PHPStorm auto-import namespaces in use statements?

phpstorm

Solution

As of today (PhpStorm 2022.1), you should select `prefer import` option in `Editor > General > Autoimport` instead of `prefer FQN`.

Problem

I have checked the box for "Enable auto-import in namespace scope" in preferences, however when I select a class from the autocomplete, the FQN remains rather than placing it in a use statement. What am I doing wrong and how can I force phpstorm to auto-import these?

Original source