php - Phpstorm Composer 类重命名
问题描述
在整个项目中,我们目前拥有:
use Twig_Environment;
// then later in the file:
Twig_Environment $twig
Twig 更新了他们的类命名空间,因此现在需要:
use Twig\Environment;
// then later in the file:
Environment $tw
Phpstorm 中是否有重构功能可以为我们处理这个问题?由于类型提示、注释等,查找/替换在这里并不理想。
解决方案
您可以通过替换简单地为该类命名:
use Twig_Environment;
和:
use Twig\Environment as Twig_Environment;
这将允许您继续使用Twig_Environment
文件中的其他任何地方。
为此,您可以使用 PHPStorm 的查找和替换功能(应该是安全的):
查找(启用正则表达式)
^\s*use\s+Twig_Environment\s*;
代替
use Twig\\Environment as Twig_Environment;
在任何情况下,特别是如果您不使用任何 VCS,您应该事先备份您的代码并确保它首先适用于几个单独的文件。
推荐阅读
- c# - 优化 linq 查询的更好方法
- php - 如何检查 foreach 循环中值为 1 的值
- reactjs - React Native 尝试为文本创建边框
- javascript - 是否可以添加 props.children 的 ref 没有 ref
- database - 在 hive 和 impala 中使用不同的分隔符创建表
- vue.js - 如何测试包装在 3rd 方组件中的代码
- typo3 - listAction() 的作用是什么?
- c# - 无效的网址在我的网站中显示为空白页面
- python - 读回保存的 LGBMClassifier 模型
- linux - KDE (KIO) 下 TransferJob 的 HTTP 错误代码