public function resolve(Request
$request, ArgumentMetadata
$argument): array
{ // with the attribute, the type can be any UserInterface implementation
// otherwise, the type must be UserInterface
if (UserInterface::
class !== $argument->
getType() && !
$argument->
getAttributesOfType(CurrentUser::
class, ArgumentMetadata::IS_INSTANCEOF
)) { return [];
} if (null ===
$user =
$this->tokenStorage->
getToken()?->
getUser()) { // if no user is present but a default value exists we use it to prevent the EntityValueResolver or others
// from attempting resolution of the User as the current logged in user was requested here
if ($argument->
hasDefaultValue()) { return [$argument->
getDefaultValue()];
} if (!
$argument->
isNullable()) { throw new AccessDeniedException(sprintf('There is no logged-in user to pass to $%s, make the argument nullable if you want to allow anonymous access to the action.',
$argument->
getName()));
} return [null
];
} if (null ===
$argument->
getType() ||
$user instanceof ($argument->
getType())) {