From 83a3134e5b5ccfcd431440928e9da3bbb8acf893 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Tue, 25 Jul 2023 15:16:12 +0200 Subject: [PATCH] Configuration: mutable dependencies shouldn't be cloned --- src/Storageless/Http/Configuration.php | 4 ++-- test/StoragelessTest/Http/ConfigurationTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Storageless/Http/Configuration.php b/src/Storageless/Http/Configuration.php index fdc3842b..78388cac 100644 --- a/src/Storageless/Http/Configuration.php +++ b/src/Storageless/Http/Configuration.php @@ -98,7 +98,7 @@ public function getClientFingerprintConfiguration(): FingerprintConfig public function withJwtConfiguration(JwtConfig $jwtConfiguration): self { $new = clone $this; - $new->jwtConfiguration = clone $jwtConfiguration; + $new->jwtConfiguration = $jwtConfiguration; return $new; } @@ -106,7 +106,7 @@ public function withJwtConfiguration(JwtConfig $jwtConfiguration): self public function withClock(Clock $clock): self { $new = clone $this; - $new->clock = clone $clock; + $new->clock = $clock; return $new; } diff --git a/test/StoragelessTest/Http/ConfigurationTest.php b/test/StoragelessTest/Http/ConfigurationTest.php index d9a60d28..2beb6b19 100644 --- a/test/StoragelessTest/Http/ConfigurationTest.php +++ b/test/StoragelessTest/Http/ConfigurationTest.php @@ -94,12 +94,12 @@ public function testImmutability(): void $jwtConfig = clone $this->jwtConfig; $rightConfig = $leftConfig->withJwtConfiguration($jwtConfig); self::assertNotSame($leftConfig, $rightConfig); - self::assertNotSame($jwtConfig, $rightConfig->getJwtConfiguration()); + self::assertSame($jwtConfig, $rightConfig->getJwtConfiguration()); $clock = FrozenClock::fromUTC(); $leftConfig = $rightConfig->withClock($clock); self::assertNotSame($leftConfig, $rightConfig); - self::assertNotSame($clock, $leftConfig->getClock()); + self::assertSame($clock, $leftConfig->getClock()); $cookie = SetCookie::create('foo'); $rightConfig = $leftConfig->withCookie($cookie);