Skip to content

Commit 358adf8

Browse files
authored
6.x config cleanup (#329)
1 parent 819f2a2 commit 358adf8

File tree

1 file changed

+37
-23
lines changed

1 file changed

+37
-23
lines changed

config/rector/sets/cakephp60.php

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
# @see https://book.cakephp.org/6/en/appendices/6-0-migration-guide.html
1515
return static function (RectorConfig $rectorConfig): void {
16+
17+
// Changes related to the accessible => patchable rename
1618
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
1719
new MethodCallRename('Cake\ORM\Entity', 'setAccess', 'setPatchable'),
1820
new MethodCallRename('Cake\ORM\Entity', 'getAccessible', 'getPatchable'),
@@ -21,35 +23,47 @@
2123

2224
$rectorConfig->ruleWithConfiguration(RenamePropertyRector::class, [
2325
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'),
4726
]);
4827

4928
$rectorConfig->ruleWithConfiguration(RenameStringRector::class, [
5029
'accessibleFields' => 'patchableFields',
5130
]);
5231

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+
5367
$staticReturnTypeMap = [
5468
'Cake\Console\BaseCommand' => ['setName'],
5569
'Cake\Controller\Controller' => [

0 commit comments

Comments
 (0)