From 20efa7b6c64898fd1301f05f5fc0b6acd7168b94 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 26 Jul 2025 13:39:53 +0530 Subject: [PATCH] Fix argument type for AuthenticationComponent::setIdentity(). It should accept an array as AuthenticationService::persistIdentity() accepts an array too. --- src/Controller/Component/AuthenticationComponent.php | 4 ++-- .../Controller/Component/AuthenticationComponentTest.php | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Controller/Component/AuthenticationComponent.php b/src/Controller/Component/AuthenticationComponent.php index 93c91f06..7ad3cc5b 100644 --- a/src/Controller/Component/AuthenticationComponent.php +++ b/src/Controller/Component/AuthenticationComponent.php @@ -300,10 +300,10 @@ public function getIdentityData(string $path): mixed * is cleared and then set to ensure that privilege escalation * and de-escalation include side effects like session rotation. * - * @param \ArrayAccess $identity Identity data to persist. + * @param \ArrayAccess|array $identity Identity data to persist. * @return $this */ - public function setIdentity(ArrayAccess $identity) + public function setIdentity(ArrayAccess|array $identity) { $controller = $this->getController(); $service = $this->getAuthenticationService(); diff --git a/tests/TestCase/Controller/Component/AuthenticationComponentTest.php b/tests/TestCase/Controller/Component/AuthenticationComponentTest.php index adc10c96..4659fd9b 100644 --- a/tests/TestCase/Controller/Component/AuthenticationComponentTest.php +++ b/tests/TestCase/Controller/Component/AuthenticationComponentTest.php @@ -214,6 +214,11 @@ public function testSetIdentity() $component->setIdentity($this->identityData); $result = $component->getIdentity(); $this->assertSame($this->identityData, $result->getOriginalData()); + + $identityData = ['id' => 99]; + $component->setIdentity($identityData); + $result = $component->getIdentity(); + $this->assertSame($identityData, $result->getOriginalData()); } /**