From a48df714f98dd0a5d3bbb09d09bec128b647945c Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 20 May 2025 21:05:05 +0200 Subject: [PATCH] add config to remove underscores from cache package methods --- config/rector/sets/cakephp60.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/config/rector/sets/cakephp60.php b/config/rector/sets/cakephp60.php index dbd1f3b1..9800a76c 100644 --- a/config/rector/sets/cakephp60.php +++ b/config/rector/sets/cakephp60.php @@ -103,4 +103,28 @@ new AddReturnTypeDeclaration('Cake\View\View', 'setPlugin', new SimpleStaticType('')), new AddReturnTypeDeclaration('Cake\View\View', 'setElementCache', new SimpleStaticType('')), ]); + + // ===== Remove underscores from method names ===== + + $map = [ + 'Cache' => [ + 'Cake\Cache\Cache' => ['_buildEngine'], + 'Cake\Cache\CacheEngine' => ['_key'], + 'Cake\Cache\Engine\FileEngine' => ['_clearDirectory', '_setKey', '_active', '_key'], + 'Cake\Cache\Engine\MemcachedEngine' => ['_setOptions'], + 'Cake\Cache\Engine\RedisEngine' => [ + '_connect', '_connectTransient', '_connectPersistent', '_createRedisInstance', + ], + ], + ]; + + foreach ($map as $definitions) { + foreach ($definitions as $className => $methods) { + foreach ($methods as $method) { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ + new MethodCallRename($className, $method, substr($method, 1)), + ]); + } + } + } };