From c826a9a833893dc7738b1fb37c77267573b11c38 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..7b96929f59 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 corresponding 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 + ); +};