{"id":10021200,"date":"2026-01-20T15:27:37","date_gmt":"2026-01-20T07:27:37","guid":{"rendered":"https:\/\/itmax.cn\/?p=10021200"},"modified":"2026-01-20T15:27:37","modified_gmt":"2026-01-20T07:27:37","slug":"rector-rules-%e6%8f%90%e4%be%9b%e6%a0%87%e5%87%86%e5%8c%96%e7%9a%84%e5%b8%b8%e9%87%8f%e3%80%81%e5%8f%98%e9%87%8f%e3%80%81%e5%87%bd%e6%95%b0%e3%80%81%e7%b1%bb%e3%80%81%e5%b1%9e%e6%80%a7%e5%92%8c","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10021200","title":{"rendered":"rector-rules &#8211; \u63d0\u4f9b\u6807\u51c6\u5316\u7684\u5e38\u91cf\u3001\u53d8\u91cf\u3001\u51fd\u6570\u3001\u7c7b\u3001\u5c5e\u6027\u548c\u65b9\u6cd5\u547d\u540d\u4ee5\u53ca\u5176\u4ed6 Rector \u89c4\u5219"},"content":{"rendered":"<h2>rector-rules &#8211; \u63d0\u4f9b\u6807\u51c6\u5316\u7684\u5e38\u91cf\u3001\u53d8\u91cf\u3001\u51fd\u6570\u3001\u7c7b\u3001\u5c5e\u6027\u548c\u65b9\u6cd5\u547d\u540d\u4ee5\u53ca\u5176\u4ed6 Rector \u89c4\u5219<\/h2>\n<blockquote>\n<p>\u4e4b\u524d\u5199\u8fc7\u7528 Rector <a href=\"https:\/\/link.segmentfault.com\/?enc=d%2FVlEsCFWyCoE%2FlckYdJtA%3D%3D.0eYQ8kfT2BGUJOiBx2ZxgD2iUk57c7nVr5ETotC6KS3r0uxYBx%2FIV73TwnD0bwXJ\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u300a\u7edf\u4e00\u89c4\u8303\u5316\u4ee3\u7801\u7684\u547d\u540d\u98ce\u683c\u300b<\/a>\uff0c\u73b0\u5728\u5df2\u7ecf\u6574\u7406\u53d1\u5e03\u4e3a Composer \u5305\u4e86\u3002<\/p>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=IndUDUkz8vtCLeLPRKw8zQ%3D%3D.2CkkLReiHR4jI9viP%2B4N9hSWjW7FbV3doXH5jtQgWIYkW54z1TxKvzmJj3fFJSvn\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">rector-rules<\/a> &#8211; \u63d0\u4f9b\u6807\u51c6\u5316\u7684\u5e38\u91cf\u3001\u53d8\u91cf\u3001\u51fd\u6570\u3001\u7c7b\u3001\u5c5e\u6027\u548c\u65b9\u6cd5\u547d\u540d\u4ee5\u53ca\u5176\u4ed6 Rector \u89c4\u5219\u3002<\/p>\n<\/blockquote>\n<h3><a href=\"https:\/\/link.segmentfault.com\/?enc=ojNql4grs5RYNPf7c7LCow%3D%3D.g%2BhxYjRjBBWkn9n5VCYkqnzv1yB9mjeUCAdl37dHfSwn9WvPG9DEeXj3TP3YeqUM4l1Qq7f52lLy%2FQJD1te8C%2BEzz4uE2nMboKB5%2B%2BN7ECk%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Rector \u89c4\u5219\u603b\u89c8<\/a><\/h3>\n<h3><a href=\"https:\/\/link.segmentfault.com\/?enc=WovyfucrBinYy3Sb%2BT%2FDew%3D%3D.IM7wVnYZI7rIZS%2BzvvonDfMMfGbOMvY60fbGultF8BHwMUhd1nyWgtcyI75QjyZIs3cBZ4TngmWwpF2CsUUJ4w%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Rector \u89c4\u5219\u96c6\u603b\u89c8<\/a><\/h3>\n<ul>\n<li><code>Guanguans\/RectorRules\/Set\/SetList::ALL<\/code><\/li>\n<li><code>Guanguans\/RectorRules\/Set\/SetList::COMMON<\/code><\/li>\n<li><code>Guanguans\/RectorRules\/Set\/SetList::PHPBENCH<\/code><\/li>\n<li><code>Guanguans\/RectorRules\/Set\/SetList::PHPSTAN<\/code><\/li>\n<li><code>Guanguans\/RectorRules\/Set\/SetList::RECTOR<\/code><\/li>\n<\/ul>\n<h3>\u914d\u7f6e\u4f7f\u7528\u89c4\u5219\u96c6\u548c\u89c4\u5219<\/h3>\n<pre><code class=\"php\">use Guanguans\/RectorRules\/Rector\/File\/SortFileFunctionStmtRector;\nuse Guanguans\/RectorRules\/Rector\/Name\/RenameToPsrNameRector;\nuse PhpParser\/NodeVisitor\/ParentConnectingVisitor;\nuse Rector\/Config\/RectorConfig;\n\nreturn RectorConfig::configure()\n    -&gt;withSets([\n        Guanguans\/RectorRules\/Set\/SetList::ALL,\n        \/\/ ...\n    ])\n    \/\/ ...\n    -&gt;registerDecoratingNodeVisitor(ParentConnectingVisitor::class)\n    -&gt;withConfiguredRule(RenameToPsrNameRector::class, [\n        'assertMatches*Snapshot', \/\/ \u6392\u9664 spatie\/pest-plugin-snapshots \u5305\u7684\u51fd\u6570\u540d\u79f0\n        'beforeEach', \/\/ \u6392\u9664 pestphp\/pest \u5305\u7684\u51fd\u6570\u540d\u79f0\n        'PDO', \/\/ \u6392\u9664 PDO \u7c7b\u540d\u79f0\n    ])\n    \/\/ ...\n    -&gt;withRules([\n        SortFileFunctionStmtRector::class,\n        \/\/ ...\n    ]);<\/code><\/pre>\n<h3>\u53e6\u5916\u63a8\u8350\u4e0b\u5176\u4ed6\u76f8\u5173\u7c7b\u4f3c\u7684\u5305<\/h3>\n<ul>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=LaWs8LK8amEuZDt%2BeiZ0sw%3D%3D.Id%2BKOhoE6aZRm%2BbQkVXSdvd2atzTy6TI5Zqj0qloY2C9e%2FTdi%2BpUzMrPfZFLqDcItTO%2BFkI9txDJ%2FL%2FS23U7Jg%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">php-cs-fixer-custom-fixers<\/a> &#8211; \u7528 php-cs-fixer \u7edf\u4e00\u4fee\u590d\u9879\u76ee\u4e2d\u7684\u975e php \u683c\u5f0f\u6587\u4ef6<\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=gIS1gW0IWlmm6VmPWpr4%2FA%3D%3D.41jBn3SyKtzMUXzRHqp5o8uNxVgFvX3gC%2F8t1OuxFgfPdR%2B0o%2F6%2FyiXspPzR9J3oIe%2Fa%2FHAJw3DSKbN7Qxqufg%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">monorepo-builder-worker<\/a> &#8211; \u7528 monorepo-builder \u81ea\u52a8\u5316\u751f\u6210 <a href=\"https:\/\/link.segmentfault.com\/?enc=c8d14jX4TSLQkJMhZh9%2FMQ%3D%3D.W6fhoFGWnqJHlVw2Y1UzR1317rAjsr66HhR5%2Fh0iDtq9bxD%2FJfv7QbZ%2BiHbhXTx4r1avu4RVclzrx9BSuGxx30X7Kb1ZgXsr2zMMSLP6%2BJQ%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">changelog<\/a> \/ \u81ea\u52a8\u5316\u9879\u76ee<a href=\"https:\/\/link.segmentfault.com\/?enc=5BQObqLwYPelQEre1QpHsw%3D%3D.H63j1%2FsiHddxOVnuIPx%2BDyEhVqb5DFGhQ%2B9o6feO8FHUPR43lDO1HhepWT6rbOI9Mlf910pq%2B4jQy7ImXAqW%2FQ%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u53d1\u5e03\u6d41\u7a0b<\/a><\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=Wee6oS07t8gLK9DZ7LeSEg%3D%3D.nUtmTm9VlerHHeo7WdUGlPiOMA7Bj4qRPnlrLe%2F6%2FP6vwfLZ3p8ga3S9mL9RQX8F\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">phpstan-rules<\/a> &#8211; \u4e00\u4e9b\u9644\u52a0\u7684 phpstan \u89c4\u5219<\/li>\n<\/ul>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000047553411\">https:\/\/segmentfault.com\/a\/1190000047553411<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>rector-rules &#8211; \u63d0\u4f9b\u6807\u51c6\u5316\u7684\u5e38\u91cf\u3001\u53d8\u91cf\u3001\u51fd\u6570\u3001\u7c7b\u3001\u5c5e\u6027\u548c\u65b9\u6cd5\u547d\u540d\u4ee5\u53ca\u5176\u4ed6 Recto [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10021200","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10021200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10021200"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10021200\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10021200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10021200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10021200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}