Skip to content

Commit 53bbc83

Browse files
authored
minor: unpack Foundry 2 proxies (#160)
- un-deprecated unpacking Foundry 1 proxies
1 parent 9603f3d commit 53bbc83

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/Browser/KernelBrowser.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
use Zenstruck\Browser\Session\Driver\BrowserKitDriver;
2222
use Zenstruck\Callback\Parameter;
2323
use Zenstruck\Foundry\Factory;
24-
use Zenstruck\Foundry\Proxy;
24+
use Zenstruck\Foundry\Persistence\Proxy;
25+
use Zenstruck\Foundry\Proxy As LegacyProxy;
2526

2627
/**
2728
* @author Kevin Bond <[email protected]>
@@ -138,11 +139,14 @@ public function actingAs(object $user, ?string $firewall = null): self
138139
$user = $user->create(); // @phpstan-ignore-line
139140
}
140141

141-
if ($user instanceof Proxy) { // @phpstan-ignore-line
142-
trigger_deprecation('zenstruck/browser', '1.9', 'Passing a Proxy to actingAs() is deprecated, pass the real object instead.');
142+
if ($user instanceof LegacyProxy) { // @phpstan-ignore-line
143143
$user = $user->object(); // @phpstan-ignore-line
144144
}
145145

146+
if ($user instanceof Proxy) { // @phpstan-ignore-line
147+
$user = $user->_real(); // @phpstan-ignore-line
148+
}
149+
146150
if (!$user instanceof UserInterface) {
147151
throw new \LogicException(\sprintf('%s() requires the user be an instance of %s.', __METHOD__, UserInterface::class));
148152
}
@@ -178,11 +182,14 @@ public function assertAuthenticated($as = null): self
178182
$as = $as->create(); // @phpstan-ignore-line
179183
}
180184

181-
if ($as instanceof Proxy) { // @phpstan-ignore-line
182-
trigger_deprecation('zenstruck/browser', '1.9', 'Passing a Proxy to assertAuthenticated() is deprecated, pass the real object instead.');
185+
if ($as instanceof LegacyProxy) { // @phpstan-ignore-line
183186
$as = $as->object(); // @phpstan-ignore-line
184187
}
185188

189+
if ($as instanceof Proxy) { // @phpstan-ignore-line
190+
$as = $as->_real(); // @phpstan-ignore-line
191+
}
192+
186193
if ($as instanceof UserInterface) {
187194
$as = $as->getUserIdentifier();
188195
}

0 commit comments

Comments
 (0)