Skip to content

Commit 08f3a05

Browse files
authored
Merge pull request #309 from cakephp/6.x-remove-underscore-methods-cache
add config to remove underscores from cache package methods
2 parents f3f0701 + a48df71 commit 08f3a05

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

config/rector/sets/cakephp60.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,28 @@
103103
new AddReturnTypeDeclaration('Cake\View\View', 'setPlugin', new SimpleStaticType('')),
104104
new AddReturnTypeDeclaration('Cake\View\View', 'setElementCache', new SimpleStaticType('')),
105105
]);
106+
107+
// ===== Remove underscores from method names =====
108+
109+
$map = [
110+
'Cache' => [
111+
'Cake\Cache\Cache' => ['_buildEngine'],
112+
'Cake\Cache\CacheEngine' => ['_key'],
113+
'Cake\Cache\Engine\FileEngine' => ['_clearDirectory', '_setKey', '_active', '_key'],
114+
'Cake\Cache\Engine\MemcachedEngine' => ['_setOptions'],
115+
'Cake\Cache\Engine\RedisEngine' => [
116+
'_connect', '_connectTransient', '_connectPersistent', '_createRedisInstance',
117+
],
118+
],
119+
];
120+
121+
foreach ($map as $definitions) {
122+
foreach ($definitions as $className => $methods) {
123+
foreach ($methods as $method) {
124+
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
125+
new MethodCallRename($className, $method, substr($method, 1)),
126+
]);
127+
}
128+
}
129+
}
106130
};

0 commit comments

Comments
 (0)