atournayre/rector-auto-upgrade
最新稳定版本:0.2.0
Composer 安装命令:
composer require atournayre/rector-auto-upgrade
包简介
Composer plugin to auto-upgrade using Rector
README 文档
README
Automate code migrations related to dependency version upgrades using Rector.
This Composer plugin enables package maintainers to provide versioned Rector sets that are automatically executed when packages are updated.
✨ Purpose
rector-auto-upgrade defines a standard for embedding versioned Rector "sets" into PHP packages, allowing automated code migration when users upgrade dependencies.
Each version of a package can provide a Rector set describing necessary changes (e.g., class renaming, method signature updates, deprecations, etc.).
📦 How It Works
- When
composer updateis executed, - The plugin detects which packages are being updated,
- For each updated package, it looks for a Rector set matching the new version,
- If found, the Rector set is executed to automatically refactor the user's code.
🗂️ Expected Package Structure
Each package providing migration support must include the following structure:
my-package/
├── rector/
│ └── sets/
│ ├── 2.0.0.php
│ ├── 2.1.0.php
- Each file name corresponds to a target version of the package.
- The content of each file must return a standard Rector configuration closure.
⚙️ Installation
composer require --dev atournayre/rector-auto-upgrade
⚠️ This plugin must only be used in a development environment.
📋 Requirements
- PHP >= 8.1
- Rector must be installed in the project.
- Composer version 2.0 or higher.
- Packages must include
rector/sets/{version}.phpfiles for their upgrades.
🧪 Example Usage
- A package
my/packageprovides a filerector/sets/2.0.0.php. - The user updates
my/packagefrom version1.4.0to2.0.0. - The plugin detects this version change, finds the matching Rector set, and runs it.
- The user’s code is automatically updated to comply with
my/packageversion2.0.0.
❗ Limitations & Recommendations
- This plugin is intended only for local.
- Use version control to review and commit changes after execution.
- Only upgrades to higher versions are currently supported.
🤝 Contributing
Feedback and contributions are welcome.
Feel free to open an issue or submit a pull request.
统计信息
- 总下载量: 831
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-06