@@ -127,18 +127,20 @@ final public function withProfiling(): self
127127 }
128128
129129 /**
130- * @param UserInterface|Proxy<UserInterface>|Factory<UserInterface> $user
130+ * @param UserInterface $user
131131 *
132132 * @return static
133133 */
134134 public function actingAs (object $ user , ?string $ firewall = null ): self
135135 {
136- if ($ user instanceof Factory) {
137- $ user = $ user ->create ();
136+ if ($ user instanceof Factory) { // @phpstan-ignore-line
137+ trigger_deprecation ('zenstruck/browser ' , '1.9 ' , 'Passing a Factory to actingAs() is deprecated, pass the created object instead. ' );
138+ $ user = $ user ->create (); // @phpstan-ignore-line
138139 }
139140
140- if ($ user instanceof Proxy) {
141- $ user = $ user ->object ();
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. ' );
143+ $ user = $ user ->object (); // @phpstan-ignore-line
142144 }
143145
144146 if (!$ user instanceof UserInterface) {
@@ -151,7 +153,7 @@ public function actingAs(object $user, ?string $firewall = null): self
151153 }
152154
153155 /**
154- * @param string|UserInterface|Proxy<UserInterface>|Factory<UserInterface>| null $as
156+ * @param string|UserInterface|null $as
155157 *
156158 * @return static
157159 */
@@ -171,12 +173,14 @@ public function assertAuthenticated($as = null): self
171173 return $ this ;
172174 }
173175
174- if ($ as instanceof Factory) {
175- $ as = $ as ->create ();
176+ if ($ as instanceof Factory) { // @phpstan-ignore-line
177+ trigger_deprecation ('zenstruck/browser ' , '1.9 ' , 'Passing a Factory to assertAuthenticated() is deprecated, pass the created object instead. ' );
178+ $ as = $ as ->create (); // @phpstan-ignore-line
176179 }
177180
178- if ($ as instanceof Proxy) {
179- $ as = $ as ->object ();
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. ' );
183+ $ as = $ as ->object (); // @phpstan-ignore-line
180184 }
181185
182186 if ($ as instanceof UserInterface) {
0 commit comments