{"id":13404788,"url":"https://github.com/rectorphp/rector","last_synced_at":"2025-05-12T18:44:17.971Z","repository":{"id":37579807,"uuid":"97311017","full_name":"rectorphp/rector","owner":"rectorphp","description":"Instant Upgrades and Automated Refactoring of any PHP 5.3+ code","archived":false,"fork":false,"pushed_at":"2025-05-05T12:19:12.000Z","size":367141,"stargazers_count":9563,"open_issues_count":1,"forks_count":714,"subscribers_count":87,"default_branch":"main","last_synced_at":"2025-05-05T12:39:00.301Z","etag":null,"topics":["ast","automated-upgrades","instant-upgrades","php","rector","upgrade"],"latest_commit_sha":null,"homepage":"https://getrector.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rectorphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"tomasvotruba"}},"created_at":"2017-07-15T11:16:02.000Z","updated_at":"2025-05-05T12:19:16.000Z","dependencies_parsed_at":"2023-10-16T16:43:01.353Z","dependency_job_id":"fb893293-f122-4094-90ee-09c4006e0fa6","html_url":"https://github.com/rectorphp/rector","commit_stats":{"total_commits":16139,"total_committers":218,"mean_commits":74.03211009174312,"dds":0.1169217423632195,"last_synced_commit":"9798fd401a7d6efb7b785e90931901c120e4e317"},"previous_names":[],"tags_count":481,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rectorphp%2Frector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rectorphp%2Frector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rectorphp%2Frector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rectorphp%2Frector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rectorphp","download_url":"https://codeload.github.com/rectorphp/rector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252526560,"owners_count":21762525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","automated-upgrades","instant-upgrades","php","rector","upgrade"],"created_at":"2024-07-30T19:01:51.445Z","updated_at":"2025-05-05T15:51:15.076Z","avatar_url":"https://github.com/rectorphp.png","language":"PHP","readme":"# Rector - Instant Upgrades and Automated Refactoring\n\n[![Downloads](https://img.shields.io/packagist/dt/rector/rector.svg?style=flat-square)](https://packagist.org/packages/rector/rector)\n\n\u003cbr\u003e\n\nRector instantly upgrades and refactors the PHP code of your application.  It can help you in 2 major areas:\n\n### 1. Instant Upgrades\n\nRector now supports upgrades from PHP 5.3 to 8.4 and major open-source projects like [Symfony](https://github.com/rectorphp/rector-symfony), [PHPUnit](https://github.com/rectorphp/rector-phpunit), and [Doctrine](https://github.com/rectorphp/rector-doctrine). Do you want to **be constantly on the latest PHP and Framework without effort**?\n\nUse Rector to handle **instant upgrades** for you.\n\n### 2. Automated Refactoring\n\nDo 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?\n\nAdd Rector to your CI and let it **continuously refactor your code** and keep the code quality high.\n\nRead our [blogpost](https://getrector.com/blog/new-setup-ci-command-to-let-rector-work-for-you) to see how to set up automated refactoring.\n\n## Install\n\n```bash\ncomposer require rector/rector --dev\n```\n\n## Running Rector\n\nThere are 2 main ways to use Rector:\n\n- a *single rule*, to have the change under control\n- or group of rules called *sets*\n\nTo use them, create a `rector.php` in your root directory:\n\n```bash\nvendor/bin/rector\n```\n\nAnd modify it:\n\n```php\nuse Rector\\Config\\RectorConfig;\nuse Rector\\TypeDeclaration\\Rector\\Property\\TypedPropertyFromStrictConstructorRector;\n\nreturn RectorConfig::configure()\n    // register single rule\n    -\u003ewithRules([\n        TypedPropertyFromStrictConstructorRector::class\n    ])\n    // here we can define, what prepared sets of rules will be applied\n    -\u003ewithPreparedSets(\n        deadCode: true,\n        codeQuality: true\n    );\n```\n\nThen dry run Rector:\n\n```bash\nvendor/bin/rector src --dry-run\n```\n\nRector will show you diff of files that it *would* change. To *make* the changes, drop `--dry-run`:\n\n```bash\nvendor/bin/rector src\n```\n\n## Documentation\n\n* Find [full documentation here](https://getrector.com/documentation/).\n* [Explore Rector Rules](https://getrector.com/find-rule)\n\n\u003cbr\u003e\n\n## Learn Faster with a Book\n\nAre you curious, how Rector works internally, how to create your own rules and test them and why Rector was born?\nRead [Rector - The Power of Automated Refactoring](https://leanpub.com/rector-the-power-of-automated-refactoring) that will take you step by step through the Rector setup and how to create your own rules.\n\n\u003cbr\u003e\n\n## Empowered by Community :heart:\n\nThe Rector community is powerful thanks to active maintainers who take care of Rector sets for particular projects.\n\nAmong there projects belong:\n\n* [palantirnet/drupal-rector](https://github.com/palantirnet/drupal-rector)\n* [craftcms/rector](https://github.com/craftcms/rector)\n* [FriendsOfShopware/shopware-rector](https://github.com/FriendsOfShopware/shopware-rector)\n* [sabbelasichon/typo3-rector](https://github.com/sabbelasichon/typo3-rector)\n* [sulu/sulu-rector](https://github.com/sulu/sulu-rector)\n* [efabrica-team/rector-nette](https://github.com/efabrica-team/rector-nette)\n* [Sylius/SyliusRector](https://github.com/Sylius/SyliusRector)\n* [CoditoNet/rector-money](https://github.com/CoditoNet/rector-money)\n* [laminas/laminas-servicemanager-migration](https://github.com/laminas/laminas-servicemanager-migration)\n* [cakephp/upgrade](https://github.com/cakephp/upgrade)\n* [driftingly/rector-laravel](https://github.com/driftingly/rector-laravel)\n* [contao/contao-rector](https://github.com/contao/contao-rector)\n* [php-static-analysis/rector-rule](https://github.com/php-static-analysis/rector-rule)\n* [ibexa/rector](https://github.com/ibexa/rector)\n  \n\u003cbr\u003e\n\n## Hire us to get Job Done :muscle:\n\nRector is a tool that [we develop](https://getrector.com/) 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**.\n\nWould you like to apply Rector on your code base but don't have time for the struggle with your project? [Hire us](https://getrector.com/contact) to get there faster.\n\n\u003cbr\u003e\n\n## How to Contribute\n\nSee [the contribution guide](/CONTRIBUTING.md) or go to development repository [rector/rector-src](https://github.com/rectorphp/rector-src).\n\n\u003cbr\u003e\n\n## Debugging\n\nYou can use `--debug` option, that will print nested exceptions output:\n\n```bash\nvendor/bin/rector src/Controller --dry-run --debug\n```\n\nOr with Xdebug:\n\n1. Make sure [Xdebug](https://xdebug.org/) is installed and configured\n2. Add `--xdebug` option when running Rector\n\n```bash\nvendor/bin/rector src/Controller --dry-run --xdebug\n```\n\nTo assist with simple debugging Rector provides 2 helpers to pretty-print AST-nodes:\n\n```php\nuse PhpParser\\Node\\Scalar\\String_;\n$node = new String_('hello world!');\n\n// prints node to string, as PHP code displays it\nprint_node($node);\n```\n\n\u003cbr\u003e\n\n## Known Drawbacks\n\n* Rector uses [nikic/php-parser](https://github.com/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.\n\n* Rector in parallel mode will work most of the times for most OS. On Windows, you may encounter issues unresolvable despite of following the [Troubleshooting Parallel](https://getrector.com/documentation/troubleshooting-parallel) guide. In such case, check if you are using Powershell 7 (pwsh). Change your terminal to command prompt (cmd) or bash for Windows.\n\n### How to Apply Coding Standards?\n\n**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.\n\nWe're using [ECS](https://github.com/symplify/easy-coding-standard) with [this setup](https://github.com/rectorphp/rector-src/blob/main/ecs.php).\n\n### May cause unexpected output on File with mixed PHP+HTML content\n\nWhen you apply changes to files with PHP + HTML content, you may need to manually verify the changed file after apply the changes.\n","funding_links":["https://github.com/sponsors/tomasvotruba"],"categories":["PHP","Generic Tools","Backend","目录","Table of Contents","By Environment","Developer Tools"],"sub_categories":["php","代码分析 Code Analysis","Code Analysis","PHP"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frectorphp%2Frector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frectorphp%2Frector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frectorphp%2Frector/lists"}