|
13 | 13 |
|
14 | 14 | # @see https://book.cakephp.org/6/en/appendices/6-0-migration-guide.html |
15 | 15 | return static function (RectorConfig $rectorConfig): void { |
| 16 | + |
| 17 | + // Changes related to the accessible => patchable rename |
16 | 18 | $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ |
17 | 19 | new MethodCallRename('Cake\ORM\Entity', 'setAccess', 'setPatchable'), |
18 | 20 | new MethodCallRename('Cake\ORM\Entity', 'getAccessible', 'getPatchable'), |
|
21 | 23 |
|
22 | 24 | $rectorConfig->ruleWithConfiguration(RenamePropertyRector::class, [ |
23 | 25 | new RenameProperty('Cake\ORM\Entity', '_accessible', 'patchable'), |
24 | | - new RenameProperty('Cake\Utility\Inflector', '_plural', 'plural'), |
25 | | - new RenameProperty('Cake\Utility\Inflector', '_singular', 'singular'), |
26 | | - new RenameProperty('Cake\Utility\Inflector', '_irregular', 'irregular'), |
27 | | - new RenameProperty('Cake\Utility\Inflector', '_uninflected', 'uninflected'), |
28 | | - new RenameProperty('Cake\Utility\Inflector', '_cache', 'cache'), |
29 | | - new RenameProperty('Cake\Utility\Inflector', '_initialState', 'initialState'), |
30 | | - new RenameProperty('Cake\Utility\Security', '_hashType', 'hashType'), |
31 | | - new RenameProperty('Cake\Utility\Security', '_salt', 'salt'), |
32 | | - new RenameProperty('Cake\Utility\Security', '_instance', 'instance'), |
33 | | - new RenameProperty('Cake\Utility\CookieCryptTrait', '_validCiphers', 'validCiphers'), |
34 | | - new RenameProperty('Cake\Utility\Text', '_defaultTransliterator', 'defaultTransliterator'), |
35 | | - new RenameProperty('Cake\Validation\Validator', '_fields', 'fields'), |
36 | | - new RenameProperty('Cake\Validation\Validator', '_providers', 'providers'), |
37 | | - new RenameProperty('Cake\Validation\Validator', '_defaultProviders', 'defaultProviders'), |
38 | | - new RenameProperty('Cake\Validation\Validator', '_presenceMessages', 'presenceMessages'), |
39 | | - new RenameProperty('Cake\Validation\Validator', '_useI18n', 'useI18n'), |
40 | | - new RenameProperty('Cake\Validation\Validator', '_allowEmptyMessages', 'allowEmptyMessages'), |
41 | | - new RenameProperty('Cake\Validation\Validator', '_allowEmptyFlags', 'allowEmptyFlags'), |
42 | | - new RenameProperty('Cake\Validation\Validator', '_stopOnFailure', 'stopOnFailure'), |
43 | | - new RenameProperty('Cake\Validation\ValidationSet', '_rules', 'rules'), |
44 | | - new RenameProperty('Cake\Validation\ValidationSet', '_validatePresent', 'validatePresent'), |
45 | | - new RenameProperty('Cake\Validation\ValidationSet', '_allowEmpty', 'allowEmpty'), |
46 | | - new RenameProperty('Cake\Validation\Validation', '_pattern', 'pattern'), |
47 | 26 | ]); |
48 | 27 |
|
49 | 28 | $rectorConfig->ruleWithConfiguration(RenameStringRector::class, [ |
50 | 29 | 'accessibleFields' => 'patchableFields', |
51 | 30 | ]); |
52 | 31 |
|
| 32 | + // ===== Remove underscores from property names ===== |
| 33 | + |
| 34 | + $map = [ |
| 35 | + 'Utility' => [ |
| 36 | + 'Cake\Utility\Inflector' => [ |
| 37 | + '_plural', '_singular', '_irregular', '_uninflected', '_cache', '_initialState', |
| 38 | + ], |
| 39 | + 'Cake\Utility\Security' => ['_hashType', '_salt', '_instance'], |
| 40 | + 'Cake\Utility\CookieCryptTrait' => ['_validCiphers'], |
| 41 | + 'Cake\Utility\Text' => ['_defaultTransliterator'], |
| 42 | + ], |
| 43 | + 'Validation' => [ |
| 44 | + 'Cake\Validation\Validator' => [ |
| 45 | + '_fields', '_providers', '_defaultProviders', '_presenceMessages', |
| 46 | + '_useI18n', '_allowEmptyMessages', '_allowEmptyFlags', '_stopOnFailure', |
| 47 | + ], |
| 48 | + 'Cake\Validation\ValidationSet' => [ |
| 49 | + '_rules', '_validatePresent', '_allowEmpty', |
| 50 | + ], |
| 51 | + 'Cake\Validation\Validation' => ['_pattern'], |
| 52 | + ], |
| 53 | + ]; |
| 54 | + |
| 55 | + foreach ($map as $definitions) { |
| 56 | + foreach ($definitions as $className => $methods) { |
| 57 | + foreach ($methods as $method) { |
| 58 | + $rectorConfig->ruleWithConfiguration(RenamePropertyRector::class, [ |
| 59 | + new RenameProperty($className, $method, substr($method, 1)), |
| 60 | + ]); |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + // ===== Add static return types ===== |
| 66 | + |
53 | 67 | $staticReturnTypeMap = [ |
54 | 68 | 'Cake\Console\BaseCommand' => ['setName'], |
55 | 69 | 'Cake\Controller\Controller' => [ |
|
0 commit comments