Skip to content

Commit

Permalink
Configuration: mutable dependencies shouldn't be cloned
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk committed Jul 25, 2023
1 parent d5ecad4 commit 83a3134
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Storageless/Http/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ public function getClientFingerprintConfiguration(): FingerprintConfig
public function withJwtConfiguration(JwtConfig $jwtConfiguration): self
{
$new = clone $this;
$new->jwtConfiguration = clone $jwtConfiguration;
$new->jwtConfiguration = $jwtConfiguration;

return $new;
}

public function withClock(Clock $clock): self
{
$new = clone $this;
$new->clock = clone $clock;
$new->clock = $clock;

return $new;
}
Expand Down
4 changes: 2 additions & 2 deletions test/StoragelessTest/Http/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 83a3134

Please sign in to comment.