From 2fdfb2abc46fea3dec5fc747002f2afdef148aac Mon Sep 17 00:00:00 2001 From: mscherer Date: Sat, 13 Dec 2025 05:41:04 +0100 Subject: [PATCH 1/2] Add rector rules for cakephp/authentication 4.x upgrade Adds rules to automate the 3.x to 4.x migration for the authentication plugin: - Rename CakeRouterUrlChecker to DefaultUrlChecker - Rename DefaultUrlChecker (framework-agnostic) to GenericUrlChecker - Rename Plugin to AuthenticationPlugin - Remove loadIdentifier() method calls See: https://github.com/cakephp/authentication/pull/748 --- config/rector/authentication40.php | 9 ++++++++ config/rector/sets/authentication40.php | 30 +++++++++++++++++++++++++ src/Rector/Set/CakePHPSetList.php | 5 +++++ 3 files changed, 44 insertions(+) create mode 100644 config/rector/authentication40.php create mode 100644 config/rector/sets/authentication40.php diff --git a/config/rector/authentication40.php b/config/rector/authentication40.php new file mode 100644 index 0000000..a2c45af --- /dev/null +++ b/config/rector/authentication40.php @@ -0,0 +1,9 @@ +sets([CakePHPSetList::AUTHENTICATION_40]); +}; diff --git a/config/rector/sets/authentication40.php b/config/rector/sets/authentication40.php new file mode 100644 index 0000000..42f6983 --- /dev/null +++ b/config/rector/sets/authentication40.php @@ -0,0 +1,30 @@ + DefaultUrlChecker -> GenericUrlChecker chain + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ + // Old framework-agnostic DefaultUrlChecker renamed to GenericUrlChecker + 'Authentication\UrlChecker\DefaultUrlChecker' => 'Authentication\UrlChecker\GenericUrlChecker', + // CakeRouterUrlChecker renamed to DefaultUrlChecker + 'Authentication\UrlChecker\CakeRouterUrlChecker' => 'Authentication\UrlChecker\DefaultUrlChecker', + // Plugin class renamed + 'Authentication\Plugin' => 'Authentication\AuthenticationPlugin', + ]); + + // Remove loadIdentifier() method calls from AuthenticationService + $rectorConfig->ruleWithConfiguration(RemoveMethodCallRector::class, [ + new RemoveMethodCall('Authentication\AuthenticationService', 'loadIdentifier'), + new RemoveMethodCall('Authentication\AuthenticationServiceInterface', 'loadIdentifier'), + ]); +}; diff --git a/src/Rector/Set/CakePHPSetList.php b/src/Rector/Set/CakePHPSetList.php index 6a0b0fc..072b7dc 100644 --- a/src/Rector/Set/CakePHPSetList.php +++ b/src/Rector/Set/CakePHPSetList.php @@ -104,4 +104,9 @@ final class CakePHPSetList * @var string */ public const CAKEPHP_FLUENT_OPTIONS = __DIR__ . '/../../../config/rector/sets/cakephp-fluent-options.php'; + + /** + * @var string + */ + public const AUTHENTICATION_40 = __DIR__ . '/../../../config/rector/sets/authentication40.php'; } From a9a481e6e8f62fa64db0f8540ed96d37a40854e7 Mon Sep 17 00:00:00 2001 From: mscherer Date: Sat, 13 Dec 2025 21:05:25 +0100 Subject: [PATCH 2/2] Rename GenericUrlChecker to StringUrlChecker --- config/rector/sets/authentication40.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/rector/sets/authentication40.php b/config/rector/sets/authentication40.php index 42f6983..f1440e2 100644 --- a/config/rector/sets/authentication40.php +++ b/config/rector/sets/authentication40.php @@ -11,11 +11,11 @@ */ return static function (RectorConfig $rectorConfig): void { // URL checker class renames - // Note: Order matters - GenericUrlChecker rename must come first to avoid - // CakeRouterUrlChecker -> DefaultUrlChecker -> GenericUrlChecker chain + // Note: Order matters - StringUrlChecker rename must come first to avoid + // CakeRouterUrlChecker -> DefaultUrlChecker -> StringUrlChecker chain $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ - // Old framework-agnostic DefaultUrlChecker renamed to GenericUrlChecker - 'Authentication\UrlChecker\DefaultUrlChecker' => 'Authentication\UrlChecker\GenericUrlChecker', + // Old DefaultUrlChecker renamed to StringUrlChecker + 'Authentication\UrlChecker\DefaultUrlChecker' => 'Authentication\UrlChecker\StringUrlChecker', // CakeRouterUrlChecker renamed to DefaultUrlChecker 'Authentication\UrlChecker\CakeRouterUrlChecker' => 'Authentication\UrlChecker\DefaultUrlChecker', // Plugin class renamed