hungthai1401/rector
Composer 安装命令:
composer require hungthai1401/rector
包简介
Instant Upgrade and Automated Refactoring of any PHP code
README 文档
README
Rector instantly upgrades and refactors the PHP code of your application. It can help you in 2 major areas:
1. Instant Upgrades
Rector now supports upgrades from PHP 5.3 to 8.1 and major open-source projects like Symfony, PHPUnit, and Doctrine. Do you want to be constantly on the latest PHP and Framework without effort?
Use Rector to handle instant upgrades for you.
2. Automated Refactoring
Do you have code quality you need, but struggle to keep it with new developers in your team? Do you want to see smart code-reviews even when every senior developers sleeps?
Add Rector to your CI and let it continuously refactor your code and keep the code quality high.
Install
composer require rector/rector --dev
Running Rector
There are 2 main ways to use Rector:
- a single rule, to have the change under control
- or group of rules called sets
To use them, create a rector.php in your root directory:
vendor/bin/rector init
And modify it:
use Rector\Config\RectorConfig; use Rector\Set\ValueObject\SetList; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector; return static function (RectorConfig $rectorConfig): void { // register single rule $rectorConfig->rule(TypedPropertyFromStrictConstructorRector::class); // here we can define, what sets of rules will be applied // tip: use "SetList" class to autocomplete sets with your IDE $rectorConfig->sets([ SetList::CODE_QUALITY ]); };
Then dry run Rector:
vendor/bin/rector process src --dry-run
Rector will show you diff of files that it would change. To make the changes, drop --dry-run:
vendor/bin/rector process src
Documentation
Learn Faster with a Book
Are you curious, how Rector works internally, how to create your own rules and test them and why Rector was born? Read Rector - The Power of Automated Refactoring that will take you step by step through the Rector setup and how to create your own rules.
Empowered by Community ❤️
The Rector community is powerful thanks to active maintainers who take care of Rector sets for particular projects.
Among there projects belong:
- palantirnet/drupal-rector
- craftcms/rector
- FriendsOfShopware/shopware-rector
- sabbelasichon/typo3-rector
- sulu/sulu-rector
- efabrica-team/rector-nette
- Sylius/SyliusRector
- CoditoNet/rector-money
- laminas/laminas-servicemanager-migration
- cakephp/upgrade
- driftingly/rector-laravel
Hire us to get Job Done 💪
Rector is a tool that we develop and share for free, so anyone can automate their refactoring. But not everyone has dozens of hours to understand complexity of abstract-syntax-tree in their own time. That's why we provide commercial support - to save your time.
Would you like to apply Rector on your code base but don't have time for the struggle with your project? Hire us to get there faster.
How to Contribute
See the contribution guide or go to development repository rector/rector-src.
Debugging
You can use --debug option, that will print nested exceptions output:
vendor/bin/rector process src/Controller --dry-run --debug
Or with Xdebug:
- Make sure Xdebug is installed and configured
- Add
--xdebugoption when running Rector
vendor/bin/rector process src/Controller --dry-run --xdebug
Known Drawbacks
How to Apply Coding Standards?
Rector uses nikic/php-parser, built on technology called an abstract syntax tree (AST). An AST doesn't know about spaces and when written to a file it produces poorly formatted code in both PHP and docblock annotations. That's why your project needs to have a coding standard tool and a set of formatting rules, so it can make Rector's output code nice and shiny again.
We're using ECS with this setup.
hungthai1401/rector 适用场景与选型建议
hungthai1401/rector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hungthai1401/rector 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hungthai1401/rector 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-04