forked from fzaninotto/Faker
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Add rector config file for easy migration (#542)
* Enhancement: Add rector config file for easy migration * Update README.md Co-authored-by: Pierre du Plessis <[email protected]> * Update README.md Co-authored-by: Andreas Möller <[email protected]> * Update rector-migrate.php Co-authored-by: Andreas Möller <[email protected]> * Update README.md Co-authored-by: Andreas Möller <[email protected]> * Add workflow * Adjust .gitignore file * Add makre target * Fix * Fix * add all properties * Fix: Use .yaml instead of .yml as extension * Remove not working code * Update rector-migrate.php * Fix: Indentation * Fix: Quote * Fix: Ignore truthy rule for 'on' * Fix: Run 'make cs' * Enhancement: Use array_map() * Fix: Avoid unnecessary imports Co-authored-by: Pierre du Plessis <[email protected]> Co-authored-by: Andreas Möller <[email protected]>
- Loading branch information
1 parent
7ae22eb
commit cbe48f7
Showing
8 changed files
with
412 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
on: # yamllint disable-line rule:truthy | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config; | ||
use Rector\Transform; | ||
|
||
// This file configures rector/rector to replace all deprecated property usages with their equivalent functions. | ||
return static function (Config\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', | ||
]; | ||
|
||
$rectorConfig->ruleWithConfiguration( | ||
Transform\Rector\Assign\PropertyFetchToMethodCallRector::class, | ||
array_map(static function (string $property): Transform\ValueObject\PropertyFetchToMethodCall { | ||
return new Transform\ValueObject\PropertyFetchToMethodCall( | ||
Generator::class, | ||
$property, | ||
$property, | ||
); | ||
}, $properties), | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
Oops, something went wrong.