gpt4 book ai didi

php - 如何在 Yii2 项目中使用 rectorphp/rector?

转载 作者:搜寻专家 更新时间:2023-10-31 21:19:28 24 4
gpt4 key购买 nike

我正在将使用 PHP 5.6 开发的 Yii 1 项目移植到使用 PHP 7.3 的 Yii 2,我想使用 rectorphp/rector 来提高代码质量并利用最新的 PHP 功能。

我已经尝试过通过 composer 和官方 Docker 镜像安装 rector。

这是我正在执行的:

vendor/bin/rector -c rector.yaml process . --level php73 --dry-run

这是所有类抛出的错误:

 [ERROR] Could not process "<my class>" file, due to:            
"Analyze error: "Class <my class> was not found while trying to
analyse it - autoloading is probably not configured properly.". Include your files in "parameters >
autoload_paths".
See https://github.com/rectorphp/rector#extra-autoloading".

我认为这个问题与 Yii2 自定义类加载器有关。

我应该如何为我的项目配置 rector?

最佳答案

我有同样的问题,直到我在 rector.yaml 中设置 autoload_paths 如下:

# rector.yaml
parameters:
autoload_paths:
- '.'

希望对你有帮助

关于php - 如何在 Yii2 项目中使用 rectorphp/rector?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57334694/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com