{"id":10021201,"date":"2026-01-20T15:27:49","date_gmt":"2026-01-20T07:27:49","guid":{"rendered":"https:\/\/itmax.cn\/?p=10021201"},"modified":"2026-01-20T15:27:49","modified_gmt":"2026-01-20T07:27:49","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-2","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10021201","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=O5g1y7MvsmYlwAh2BgMmAw%3D%3D.sncN7CB3IhJglrA5ooiORPxarYWUlp8VfgQb5D46JmoUvaeGg2LWyyJVNZWBA1Qe\" 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=%2FukRQZggYlgQe2OmzYj6PA%3D%3D.88zt6MBG6msQCCdfE2ZGOm1mT3fhbgi7GOA9IDo0s1H38pqROVNUCCSGgdGaKh3g\" 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=pN3aNcMFea3Bw9KTL9WxKA%3D%3D.9qep3S0VafY1FyAex44bUca16u0cnWLDSBO7WkI3X4%2FkmW3FSHvEFlWGKcvnVXVtIVzfYoyz08vDYexM%2Bk4o7j79Byig3s0Vs9bOkhSP9dI%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Rector \u89c4\u5219\u603b\u89c8<\/a><\/h3>\n<h3><a href=\"https:\/\/link.segmentfault.com\/?enc=wVIYhWw%2BtnlanBVCBrkKXw%3D%3D.xKQvPw%2B2ttwK4zbwbunUh9hrj%2F2b376bp%2BIzwpHxCiKQnbVyve0SwU9qNWKqEk2oo4XbPIQhHZZGQD5uqX5ZzQ%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=p7a56o4MsO7gEk8Rv4kekg%3D%3D.H1PsVA2WsMKwEZNznJ3a8J%2BbgVpCl%2FWT0N2s6LVP9Lp1ob5Yj3n470rqRuD8kZKYmouM8BkxROVf7AOGfDgXWA%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=TcN9C%2F5ZZPVFjBPZg3Ue3w%3D%3D.BuanVYJHilBGlTAUP7kVI1JKYuf411eZ0r%2FbqXW8X8MLAcyLIvA8OWz2iM0I%2B%2FIfZqGoCU0t18ZTFhB0HWN76A%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=jtlgXNKEiKrIsrg968W6ew%3D%3D.msQMJ7dI0966MTnMdZ4UgFnoP91UfGwMlSIX%2FTJEJFYEko%2Fj0n6lGVBbvE2dUYDZutwayJ1Qrypvv8SnZbPdWdWff4EGTOPz5owplmEnVXA%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">changelog<\/a> \/ \u81ea\u52a8\u5316\u9879\u76ee<a href=\"https:\/\/link.segmentfault.com\/?enc=zhqEKUbDZp7UWMlq4%2FiK2Q%3D%3D.cOM7RcoueCrpOciskkbqPGv59psJP0CbvOG4%2FbpofbH0GPuclbqPBNjt4zx3D0Jdy2tvK6HOPyY8rs6PfPdnUQ%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u53d1\u5e03\u6d41\u7a0b<\/a><\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=SaNizkg6X0Yculs673ewpw%3D%3D.I8lnFDCHUqa0tFcccCeulHHB%2FOs543n1rGWA6FQKO7WQN7YbUpRHoxVl8gX%2F2R6m\" 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\/1190000047553406\">https:\/\/segmentfault.com\/a\/1190000047553406<\/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":1,"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-10021201","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\/10021201","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10021201"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10021201\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10021201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10021201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10021201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}