if(!interface_exists(UserInterface::class)){ thrownew \LogicException(sprintf('"%s" requires symfony/security-core to be installed. Try running "composer require symfony/security-core".', __METHOD__)); }
if(!$user instanceof UserInterface){ thrownew \LogicException(sprintf('The first argument of "%s" must be instance of "%s", "%s" provided.', __METHOD__, UserInterface::class, get_debug_type($user))); }
$token = newTestBrowserToken($user->getRoles(), $user, $firewallContext); $token->setAttributes($tokenAttributes); // required for compatibility with Symfony 5.4
if(method_exists($token, 'isAuthenticated')){ $token->setAuthenticated(true, false); }