PHP code example of yangweijie / aot-rector
1. Go to this page and download the library: Download yangweijie/aot-rector library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yangweijie / aot-rector example snippets
->withSkip([
// ... 默认跳过规则 ...
'vendor/topthink/framework/src/think/exception/Handle.php',
'vendor/topthink/think-helper/src/helper/Arr.php',
// 你的项目中解析报错的文件
])
->withSkip([
// 测试文件
'*/Tests/*', '*/tests/*', '*/Test/*', '*/test/*',
// Composer 自动生成文件
'*/vendor/autoload.php',
'*/vendor/composer/*',
// Rector 自身(避免嵌套 vendor/ 循环)
'vendor/rector/**',
// Rector 解析器不支持的语法
'vendor/symfony/polyfill-*/**',
'vendor/symfony/var-dumper/**',
// 项目中解析报错的特定文件
'vendor/topthink/framework/src/think/exception/Handle.php',
'vendor/topthink/framework/src/think/view/driver/Php.php',
'vendor/topthink/think-helper/src/helper/Arr.php',
// 非 PHP 文件
'*.json', '*.yml', '*.yaml', '*.xml', '*.neon', '*.md', '*.dist',
])
// ———— 输入(转换前) ————
$name = 'foo';
$$name = 'hello';
bash
cp vendor/yangweijie/aot-rector/rector.php.dist rector.php
tests/Rules/Fixtures/{RuleName}/
├── some_feature.php.inc # 转换测试
├── skip_passthrough.php.inc # 不做转换的测试(无 ----- 分隔符)
└── ...