From 78eb80ad595719edc2a97c59a98d59626ba29b6d Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 5 Dec 2022 06:48:50 +0100 Subject: [PATCH 01/20] 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..e49156de43 --- /dev/null +++ b/rector-migrate.php @@ -0,0 +1,41 @@ +ruleWithConfiguration( + PropertyFetchToMethodCallRector::class, + $methodCalls + ); +}; From 4747c53f826e860107ac4e8742a478b65b408c1b Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 5 Dec 2022 08:23:29 +0100 Subject: [PATCH 02/20] Update README.md Co-authored-by: Pierre du Plessis --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fe522ef1b5..df8e38ed11 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ to run `rector/rector`. Another way is to use it in your `rector.php` file: ```php -$faker = require 'vendor/fakerphp/faker/rector-migrate.php'; +$rectorConfig->import('vendor/fakerphp/faker/rector-migrate.php'); $faker($rectorConfig); ``` From 67f47eaca0079e5626c0d33c186e8f0d9b700171 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 5 Dec 2022 15:54:27 +0100 Subject: [PATCH 03/20] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Andreas Möller --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index df8e38ed11..846437c9da 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ 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. +*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: From 14d8c0b0b6bc415446a69002b5741d5b71bf43b9 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 5 Dec 2022 15:54:36 +0100 Subject: [PATCH 04/20] Update rector-migrate.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Andreas Möller --- rector-migrate.php | 1 + 1 file changed, 1 insertion(+) diff --git a/rector-migrate.php b/rector-migrate.php index e49156de43..493d6483ba 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -30,6 +30,7 @@ ]; $methodCalls = []; + foreach ($properties as $property) { $methodCalls[] = new PropertyFetchToMethodCall(Generator::class, $property, $property); } From e68e9f9c10f6e111740ace1afd744657ba55cbe4 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 5 Dec 2022 15:54:42 +0100 Subject: [PATCH 05/20] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Andreas Möller --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 846437c9da..d57c1bc1ce 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ You can use the provided [Rector](https://github.com/rectorphp/rector) config fi Run ```bash -$ composer require --dev rector/rector +composer require --dev rector/rector ``` to install `rector/rector`. From b56551f73d6e43ba5a64ce0dc748bd308b79e281 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 5 Dec 2022 15:56:37 +0100 Subject: [PATCH 06/20] Add workflow --- .github/workflows/rector.yml | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/rector.yml diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml new file mode 100644 index 0000000000..a7fe1cc97f --- /dev/null +++ b/.github/workflows/rector.yml @@ -0,0 +1,52 @@ +on: + pull_request: ~ + push: + branches: + - "main" + - "[0-9].*" + +name: Rector + +jobs: + rector: + name: Rector + + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: + - 8.1 + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + coverage: none + extensions: intl + php-version: ${{ matrix.php-version }} + + - name: Determine composer cache directory + id: composer-cache + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies installed with composer + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.directory }} + key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} + restore-keys: | + composer-${{ runner.os }}-${{ matrix.php-version }}- + composer-${{ runner.os }}- + composer- + + - name: Download dependencies + run: | + composer update --no-interaction --no-progress --optimize-autoloader + composer bin rector install --no-interaction --no-progress --optimize-autoloader + + - name: Run rector + run: vendor/bin/rector process test/ --config=rector-migrate.php --dry-run From c3adb4f98c21c9376c4a769bb368737aafe905b8 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 5 Dec 2022 15:58:34 +0100 Subject: [PATCH 07/20] Adjust .gitignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a65c611c9c..1305898a0c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ /vendor-bin/php-cs-fixer/vendor/ /vendor-bin/phpstan/vendor/ /vendor-bin/psalm/vendor/ +/vendor-bin/rector/vendor/ /.php-cs-fixer.cache /composer.lock From ba419de63747fccc8150a3d9eff9b22abf142b27 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 5 Dec 2022 15:58:51 +0100 Subject: [PATCH 08/20] Add makre target --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index f9f5d44b91..a130e453f5 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,10 @@ coverage: vendor ## Collects coverage with phpunit test: vendor ## Runs tests with phpunit vendor/bin/simple-phpunit +.PHONY: rector +rector: vendor ## Runs rector + vendor/bin/rector process test/ --config=rector-migrate.php --dry-run + .PHONY: static static: vendor ## Runs static analyzers vendor/bin/phpstan From 73804fe07611db93e8bfeb5d52dc26e386725117 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 5 Dec 2022 16:00:24 +0100 Subject: [PATCH 09/20] Fix --- vendor-bin/rector/composer.json | 13 +++ vendor-bin/rector/composer.lock | 139 ++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 vendor-bin/rector/composer.json create mode 100644 vendor-bin/rector/composer.lock diff --git a/vendor-bin/rector/composer.json b/vendor-bin/rector/composer.json new file mode 100644 index 0000000000..6cd9a82381 --- /dev/null +++ b/vendor-bin/rector/composer.json @@ -0,0 +1,13 @@ +{ + "require": { + "php": "^8.1", + "rector/rector": "^0.15.0" + }, + "config": { + "platform": { + "php": "8.1.12" + }, + "preferred-install": "dist", + "sort-packages": true + } +} diff --git a/vendor-bin/rector/composer.lock b/vendor-bin/rector/composer.lock new file mode 100644 index 0000000000..ca0fbed694 --- /dev/null +++ b/vendor-bin/rector/composer.lock @@ -0,0 +1,139 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "be38cafadfc09ca7ff05a317facfa0d5", + "packages": [ + { + "name": "phpstan/phpstan", + "version": "1.9.2", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "d6fdf01c53978b6429f1393ba4afeca39cc68afa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d6fdf01c53978b6429f1393ba4afeca39cc68afa", + "reference": "d6fdf01c53978b6429f1393ba4afeca39cc68afa", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.9.2" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2022-11-10T09:56:11+00:00" + }, + { + "name": "rector/rector", + "version": "0.15.0", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "fbfbe499d0fedfac7fe2fed1a55a00bd08f19c91" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/fbfbe499d0fedfac7fe2fed1a55a00bd08f19c91", + "reference": "fbfbe499d0fedfac7fe2fed1a55a00bd08f19c91", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0", + "phpstan/phpstan": "^1.9.2" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-php-parser": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.14-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/0.15.0" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2022-12-04T22:40:18+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^8.1" + }, + "platform-dev": [], + "platform-overrides": { + "php": "8.1.12" + }, + "plugin-api-version": "2.3.0" +} From 12c6aa6e24c0548decab459c3b2bbd18fd753b6e Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 5 Dec 2022 16:12:00 +0100 Subject: [PATCH 10/20] Fix --- .github/dependabot.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f53d0f2412..eb2205218f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -39,6 +39,18 @@ updates: interval: "monthly" versioning-strategy: "increase" + - commit-message: + include: "scope" + prefix: "composer" + directory: "/vendor-bin/rector" + labels: + - "dependency" + open-pull-requests-limit: 10 + package-ecosystem: "composer" + schedule: + interval: "monthly" + versioning-strategy: "increase" + - commit-message: include: "scope" prefix: "github-actions" From d0d4e1c223abcee462caada5420dc95ad93beb70 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 5 Dec 2022 16:16:53 +0100 Subject: [PATCH 11/20] add all properties --- rector-migrate.php | 123 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/rector-migrate.php b/rector-migrate.php index 493d6483ba..cd9b206590 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -9,29 +9,152 @@ // This file configures rector/rector to replace all deprecated property usages with their equivalent functions. return static function (RectorConfig $rectorConfig): void { $properties = [ + 'address', + 'amPm', + 'asciify', + 'biasedNumberBetween', 'boolean', + 'bothify', + 'buildingNumber', + 'century', + 'chrome', 'city', + 'citySuffix', + 'colorName', + 'company', + 'companyEmail', + 'companySuffix', + 'country', + 'countryCode', + 'countryISOAlpha3', + 'creditCardDetails', + 'creditCardExpirationDate', + 'creditCardExpirationDateString', + 'creditCardNumber', + 'creditCardType', + 'currencyCode', + 'date', 'dateTime', + 'dateTimeAD', + 'dateTimeBetween', + 'dateTimeInInterval', + 'dateTimeThisCentury', + 'dateTimeThisDecade', + 'dateTimeThisMonth', 'dateTimeThisYear', + 'dayOfMonth', + 'dayOfWeek', + 'domainName', + 'domainWord', + 'e164PhoneNumber', 'email', + 'emoji', + 'file', + 'firefox', 'firstName', 'firstNameFemale', + 'firstNameMale', + 'freeEmail', + 'freeEmailDomain', + 'getDefaultTimezone', + 'hexColor', + 'hslColor', + 'hslColorAsArray', + 'iban', + 'image', + 'imageUrl', + 'imei', + 'internetExplorer', + 'iosMobileToken', + 'ipv4', + 'ipv6', + 'iso8601', + 'jobTitle', + 'languageCode', 'lastName', + 'latitude', + 'lexify', + 'linuxPlatformToken', + 'linuxProcessor', + 'localCoordinates', + 'localIpv4', + 'locale', + 'longitude', + 'macAddress', + 'macPlatformToken', + 'macProcessor', + 'md5', + 'month', + 'monthName', + 'msedge', 'name', + 'numerify', + 'opera', + 'paragraph', + 'paragraphs', + 'passthrough', 'password', 'phoneNumber', + 'postcode', + 'randomAscii', + 'randomDigitNotNull', + 'randomElement', + 'randomElements', + 'randomHtml', + 'randomKey', + 'randomLetter', + 'realText', + 'realTextBetween', + 'regexify', + 'rgbColor', + 'rgbColorAsArray', + 'rgbCssColor', + 'rgbaCssColor', + 'safari', + 'safeColorName', + 'safeEmail', + 'safeEmailDomain', + 'safeHexColor', 'sentence', + 'sentences', + 'setDefaultTimezone', + 'sha1', 'sha256', + 'shuffle', + 'shuffleArray', + 'shuffleString', 'slug', + 'streetAddress', + 'streetName', + 'streetSuffix', + 'swiftBicNumber', 'text', + 'time', + 'timezone', + 'title', + 'titleFemale', + 'titleMale', + 'tld', + 'toLower', + 'toUpper', + 'unixTime', 'url', + 'userAgent', + 'userName', + 'uuid', + 'windowsPlatformToken', 'word', 'words', + 'year', ]; $methodCalls = []; foreach ($properties as $property) { + if (!property_exists(\Faker\Generator::class, $property)) { + throw new \InvalidArgumentException(sprintf('Property "%s" does not exist in class "%s"', $property, \Faker\Generator::class)); + } + $methodCalls[] = new PropertyFetchToMethodCall(Generator::class, $property, $property); } From 65479e777c975ab3544d193945ab8b929660a49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Tue, 13 Dec 2022 10:45:15 +0100 Subject: [PATCH 12/20] Fix: Use .yaml instead of .yml as extension --- .github/workflows/{rector.yml => rector.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{rector.yml => rector.yaml} (100%) diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yaml similarity index 100% rename from .github/workflows/rector.yml rename to .github/workflows/rector.yaml From fc495dbbd920d18209aa9b7884f68c3de3b6459e Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 13 Dec 2022 10:46:38 +0100 Subject: [PATCH 13/20] Remove not working code --- rector-migrate.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/rector-migrate.php b/rector-migrate.php index cd9b206590..c39a98f5fa 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -151,9 +151,6 @@ $methodCalls = []; foreach ($properties as $property) { - if (!property_exists(\Faker\Generator::class, $property)) { - throw new \InvalidArgumentException(sprintf('Property "%s" does not exist in class "%s"', $property, \Faker\Generator::class)); - } $methodCalls[] = new PropertyFetchToMethodCall(Generator::class, $property, $property); } From 1f72ab000f626eaebd9759ea68323d90042a7197 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 13 Dec 2022 10:46:52 +0100 Subject: [PATCH 14/20] Update rector-migrate.php --- rector-migrate.php | 1 - 1 file changed, 1 deletion(-) diff --git a/rector-migrate.php b/rector-migrate.php index c39a98f5fa..64e4990ce1 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -151,7 +151,6 @@ $methodCalls = []; foreach ($properties as $property) { - $methodCalls[] = new PropertyFetchToMethodCall(Generator::class, $property, $property); } From 8d19e5e76e000366fc099bbd83ae4372fc1c0768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Tue, 13 Dec 2022 10:47:13 +0100 Subject: [PATCH 15/20] Fix: Indentation --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index eb2205218f..baa3fe3b7e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -44,7 +44,7 @@ updates: prefix: "composer" directory: "/vendor-bin/rector" labels: - - "dependency" + - "dependency" open-pull-requests-limit: 10 package-ecosystem: "composer" schedule: From 54770f772921fcc9c6f5e7055456ac9ae763ce85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Tue, 13 Dec 2022 10:49:11 +0100 Subject: [PATCH 16/20] Fix: Quote --- .github/workflows/rector.yaml | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/rector.yaml b/.github/workflows/rector.yaml index a7fe1cc97f..23056df8ce 100644 --- a/.github/workflows/rector.yaml +++ b/.github/workflows/rector.yaml @@ -5,48 +5,48 @@ on: - "main" - "[0-9].*" -name: Rector +name: "Rector" jobs: rector: - name: Rector + name: "Rector" - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" strategy: matrix: php-version: - - 8.1 + - "8.1" steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: "Checkout code" + uses: "actions/checkout@v3" - - name: Set up PHP - uses: shivammathur/setup-php@v2 + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" with: - coverage: none - extensions: intl - php-version: ${{ matrix.php-version }} + coverage: "none" + extensions: "intl" + php-version: "${{ matrix.php-version }}" - - name: Determine composer cache directory - id: composer-cache - run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + - name: "Determine composer cache directory" + id: "composer-cache" + run: "echo \"directory=$(composer config cache-dir)\" >> $GITHUB_OUTPUT" - - name: Cache dependencies installed with composer - uses: actions/cache@v3 + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v3" with: - path: ${{ steps.composer-cache.outputs.directory }} - key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} + path: "${{ steps.composer-cache.outputs.directory }}" + key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}" restore-keys: | composer-${{ runner.os }}-${{ matrix.php-version }}- composer-${{ runner.os }}- composer- - - name: Download dependencies + - name: "Download dependencies" run: | composer update --no-interaction --no-progress --optimize-autoloader composer bin rector install --no-interaction --no-progress --optimize-autoloader - - name: Run rector - run: vendor/bin/rector process test/ --config=rector-migrate.php --dry-run + - name: "Run rector" + run: "vendor/bin/rector process test/ --config=rector-migrate.php --dry-run" From 47b7ead4e75ffc82ba8b186d73cc340c93975dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Tue, 13 Dec 2022 10:49:39 +0100 Subject: [PATCH 17/20] Fix: Ignore truthy rule for 'on' --- .github/workflows/rector.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rector.yaml b/.github/workflows/rector.yaml index 23056df8ce..f6f338300a 100644 --- a/.github/workflows/rector.yaml +++ b/.github/workflows/rector.yaml @@ -1,4 +1,4 @@ -on: +on: # yamllint disable-line rule:truthy pull_request: ~ push: branches: From 7f9065da6f8f4e6af9a80920907ff856ee9ee9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Tue, 13 Dec 2022 10:49:49 +0100 Subject: [PATCH 18/20] Fix: Run 'make cs' --- rector-migrate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rector-migrate.php b/rector-migrate.php index 64e4990ce1..2a077b2666 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -156,6 +156,6 @@ $rectorConfig->ruleWithConfiguration( PropertyFetchToMethodCallRector::class, - $methodCalls + $methodCalls, ); }; From f6baaf21c6ee43dc3b31264fdf5822fc3fdddc04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Tue, 13 Dec 2022 10:54:11 +0100 Subject: [PATCH 19/20] Enhancement: Use array_map() --- rector-migrate.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rector-migrate.php b/rector-migrate.php index 2a077b2666..6e65bc48fd 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -148,14 +148,14 @@ 'year', ]; - $methodCalls = []; - - foreach ($properties as $property) { - $methodCalls[] = new PropertyFetchToMethodCall(Generator::class, $property, $property); - } - $rectorConfig->ruleWithConfiguration( PropertyFetchToMethodCallRector::class, - $methodCalls, + array_map(static function (string $property): PropertyFetchToMethodCall { + return new PropertyFetchToMethodCall( + Generator::class, + $property, + $property, + ); + }, $properties), ); }; From eb5b3aae07f362f4d64a596805f86898349dc1b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Tue, 13 Dec 2022 10:54:54 +0100 Subject: [PATCH 20/20] Fix: Avoid unnecessary imports --- rector-migrate.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rector-migrate.php b/rector-migrate.php index 6e65bc48fd..2839c8b179 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -2,12 +2,11 @@ declare(strict_types=1); -use Rector\Config\RectorConfig; -use Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector; -use Rector\Transform\ValueObject\PropertyFetchToMethodCall; +use Rector\Config; +use Rector\Transform; // This file configures rector/rector to replace all deprecated property usages with their equivalent functions. -return static function (RectorConfig $rectorConfig): void { +return static function (Config\RectorConfig $rectorConfig): void { $properties = [ 'address', 'amPm', @@ -149,9 +148,9 @@ ]; $rectorConfig->ruleWithConfiguration( - PropertyFetchToMethodCallRector::class, - array_map(static function (string $property): PropertyFetchToMethodCall { - return new PropertyFetchToMethodCall( + Transform\Rector\Assign\PropertyFetchToMethodCallRector::class, + array_map(static function (string $property): Transform\ValueObject\PropertyFetchToMethodCall { + return new Transform\ValueObject\PropertyFetchToMethodCall( Generator::class, $property, $property,