Download the PHP package yangweijie/aot-rector without Composer
On this page you can find all versions of the php package yangweijie/aot-rector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download yangweijie/aot-rector
More information about yangweijie/aot-rector
Files in yangweijie/aot-rector
Download yangweijie/aot-rector
More information about yangweijie/aot-rector
Files in yangweijie/aot-rector
Vendor yangweijie
Package aot-rector
Short Description Rector rules for transforming PHP code to be compatible with Swoole AOT Compiler
License MIT
Package aot-rector
Short Description Rector rules for transforming PHP code to be compatible with Swoole AOT Compiler
License MIT
Please rate this library. Is it a good library?
Informations about the package aot-rector
AOT Rector Rules
将 vendor 目录中的第三方 PHP 代码转换为兼容 Swoole AOT Compiler 语法的自动化工具。
工作原理
规则列表
| 规则 | 针对语法 | 操作 |
|---|---|---|
DollarDollarToArrayAccessRector |
$$var 动态变量 |
转为 $_dyn_vars[$key] |
ExtractToManualAssignmentRector |
extract() 函数 |
替换为参数表达式 + 注释提醒 |
MultiBreakContinueRector |
break N / continue N |
添加注释提醒改用 goto |
StringNullByteRector |
字符串字面量中含 \0 |
替换为 "str".chr(0)."续" |
FreeCodeToFunctionRector |
游离代码(不在函数内) | 标记检测结果 |
ClosureRefParamToRefvalRector |
闭包引用参数 &$var |
添加注释提醒使用 refval() |
安装
配置
1. rector.php
复制模板到项目根目录:
根据项目的 vendor 依赖,在 withSkip 中添加需要跳过的文件:
2. composer.json 脚本
Composer 脚本不会自动从依赖包继承,需要在根项目的 composer.json 中添加:
命令参考
| 命令 | 说明 |
|---|---|
composer aot:rector |
完整流程:Rector 转换 → 生成补丁 → 应用到 vendor |
composer aot:rector-dry |
预览:只显示 Rector 会改哪些文件,不改写 |
vendor/bin/aot-patch |
仅补丁:对比 @aot/ 和 vendor/,生成补丁并应用 |
composer aot:patch |
同上(通过 composer 脚本) |
首次运行:
后续如果修改了 patches/ 中的补丁文件,重新执行 composer aot:rector 或 vendor/bin/aot-patch 即可同步到 vendor。
目录说明
跳过规则配置
rector.php 中 withSkip 的常见配置项:
注意:被跳过的文件不会被 Rector 转换,但不影响 AOT 编译。AOT 编译器使用 ZendPHP 自己的解析器而非 Rector 的
nikic/php-parser。
开发
运行测试
测试夹具结构
夹具格式:
Patcher 类
Aot\Rector\Patcher— 补丁生成和应用Aot\Rector\PatcherConfig— 路径配置常量bin/aot-patch— CLI 入口(Composer bin 脚本)
路径解析使用 getcwd() 获取项目根目录,因此可以在任意目录执行。
All versions of aot-rector with dependencies
PHP Build Version
Package Version
The package yangweijie/aot-rector contains the following files
Loading the files please wait ...