From 78bba13e47f46f25806113330cfe003bd6e6741e Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 5 Dec 2022 06:48:50 +0100 Subject: [PATCH] Enhancement: Add rector config file for easy migration --- README.md | 31 +++++++++++++++++++++++++++++++ rector-migrate.php | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 rector-migrate.php diff --git a/README.md b/README.md index 018c70bb7e..fe522ef1b5 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,37 @@ for ($i = 0; $i < 3; $i++) { // 'Orlo Bergstrom' ``` +## Automated refactoring + +If you already used this library with its properties, they are now deprecated and needs to be replaced by their equivalent methods. + +You can use the provided [Rector](https://github.com/rectorphp/rector) config file to automate the work. + +Run + +```bash +$ composer require --dev rector/rector +``` + +to install `rector/rector`. + +Run + +```bash +vendor/bin/rector process src/ --config vendor/fakerphp/faker/rector-migrate.php +``` + +to run `rector/rector`. + +*Note:* do not forget to replace "src/" with the path to your source directory. + +Another way is to use it in your `rector.php` file: + +```php +$faker = require 'vendor/fakerphp/faker/rector-migrate.php'; +$faker($rectorConfig); +``` + ## License Faker is released under the MIT License. See [`LICENSE`](LICENSE) for details. diff --git a/rector-migrate.php b/rector-migrate.php new file mode 100644 index 0000000000..ebd09b9cbf --- /dev/null +++ b/rector-migrate.php @@ -0,0 +1,41 @@ +ruleWithConfiguration( + PropertyFetchToMethodCallRector::class, + $methodCalls + ); +};