【问题标题】:How to make PhpStorm add an import for root classes?如何让 PhpStorm 为根类添加导入?
【发布时间】:2020-09-28 20:38:12
【问题描述】:

当我开始输入类名并从下拉列表中选择一个类时,PhpStorm 使用短类名并自动在文件顶部添加导入,这非常方便:

但是,当我对根类执行相同操作时,PhpStorm 使用 FQCN,将 \ 添加到类名之前,并且在文件顶部不添加任何导入语句:

有没有办法将 PhpStorm 配置为也始终为根类使用短类名?

【问题讨论】:

    标签: phpstorm


    【解决方案1】:

    当然,只需为PHP | Treat symbols from the global space 部分下的Class 下拉框使用适当的选项:确保它是“首选导入”而不是“首选 FQN”。

    该选项位于Settings/Preferences | Editor | General | Auto Import

    【讨论】:

    • 效果很好。谢谢!
    猜你喜欢
    • 2019-10-07
    • 1970-01-01
    • 1970-01-01
    • 2012-10-24
    • 2021-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多