Skip to content

Commit 20efa7b

Browse files
committed
Fix argument type for AuthenticationComponent::setIdentity().
It should accept an array as AuthenticationService::persistIdentity() accepts an array too.
1 parent 058de14 commit 20efa7b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Controller/Component/AuthenticationComponent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,10 @@ public function getIdentityData(string $path): mixed
300300
* is cleared and then set to ensure that privilege escalation
301301
* and de-escalation include side effects like session rotation.
302302
*
303-
* @param \ArrayAccess $identity Identity data to persist.
303+
* @param \ArrayAccess|array $identity Identity data to persist.
304304
* @return $this
305305
*/
306-
public function setIdentity(ArrayAccess $identity)
306+
public function setIdentity(ArrayAccess|array $identity)
307307
{
308308
$controller = $this->getController();
309309
$service = $this->getAuthenticationService();

tests/TestCase/Controller/Component/AuthenticationComponentTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ public function testSetIdentity()
214214
$component->setIdentity($this->identityData);
215215
$result = $component->getIdentity();
216216
$this->assertSame($this->identityData, $result->getOriginalData());
217+
218+
$identityData = ['id' => 99];
219+
$component->setIdentity($identityData);
220+
$result = $component->getIdentity();
221+
$this->assertSame($identityData, $result->getOriginalData());
217222
}
218223

219224
/**

0 commit comments

Comments
 (0)