forked from fzaninotto/Faker
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
- Loading branch information
1 parent
504778e
commit c826a9a
Showing
2 changed files
with
72 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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector; | ||
use Rector\Transform\ValueObject\PropertyFetchToMethodCall; | ||
|
||
// This file configures rector/rector to replace all deprecated property usages with their equivalent functions. | ||
return static function (RectorConfig $rectorConfig): void { | ||
$properties = [ | ||
'boolean', | ||
'city', | ||
'dateTime', | ||
'dateTimeThisYear', | ||
'email', | ||
'firstName', | ||
'lastName', | ||
'firstNameFemale', | ||
'name', | ||
'password', | ||
'phoneNumber', | ||
'sentence', | ||
'sha256', | ||
'slug', | ||
'text', | ||
'url', | ||
'word', | ||
'words', | ||
]; | ||
|
||
$methodCalls = []; | ||
foreach ($properties as $property) { | ||
$methodCalls[] = new PropertyFetchToMethodCall(Generator::class, $property, $property); | ||
} | ||
|
||
$rectorConfig->ruleWithConfiguration( | ||
PropertyFetchToMethodCallRector::class, | ||
$methodCalls | ||
); | ||
}; |