8000 Fix deprecation messages by fabpot · Pull Request #42534 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Fix deprecation messages #42534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function createNewToken(PersistentTokenInterface $token)
$sql = 'INSERT INTO rememberme_token (class, username, series, value, lastUsed) VALUES (:class, :username, :series, :value, :lastUsed)';
$paramValues = [
'class' => $token->getClass(),
// @deprecated since 5.3, change to $token->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $token->getUserIdentifier() in 6.0
'username' => method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername(),
'series' => $token->getSeries(),
'value' => $token->getTokenValue(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function loadUserByIdentifier(string $identifier): UserInterface
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, get_debug_type($repository)));
}

// @deprecated since 5.3, change to $repository->loadUserByIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $repository->loadUserByIdentifier() in 6.0
if (method_exists($repository, 'loadUserByIdentifier')) {
$user = $repository->loadUserByIdentifier($identifier);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __invoke(array $record): array
'roles' => $token->getRoleNames(),
];

// @deprecated since 5.3, change to $token->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $token->getUserIdentifier() in 6.0
if (method_exists($token, 'getUserIdentifier')) {
$record['extra'][$this->getKey()]['username'] = $record['extra'][$this->getKey()]['user_identifier'] = $token->getUserIdentifier();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function collect(Request $request, Response $response, \Throwable $except
$impersonatorUser = null;
if ($token instanceof SwitchUserToken) {
$originalToken = $token->getOriginalToken();
// @deprecated since 5.3, change to $originalToken->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $originalToken->getUserIdentifier() in 6.0
$impersonatorUser = method_exists($originalToken, 'getUserIdentifier') ? $originalToken->getUserIdentifier() : $originalToken->getUsername();
}

Expand Down Expand Up @@ -130,7 +130,7 @@ public function collect(Request $request, Response $response, \Throwable $except
'token' => $token,
'token_class' => $this->hasVarDumper ? new ClassStub(\get_class($token)) : \get_class($token),
'logout_url' => $logoutUrl,
// @deprecated since 5.3, change to $token->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $token->getUserIdentifier() in 6.0
'user' => method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername(),
'roles' => $assignedRoles,
'inherited_roles' => array_unique($inheritedRoles),
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Helper/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function getHelperSet()
/**
* Returns the length of a string, using mb_strwidth if it is available.
*
* @deprecated since 5.3
* @deprecated since Symfony 5.3
*
* @return int The length of the string
*/
Expand Down Expand Up @@ -154,7 +154,7 @@ public static function formatMemory(int $memory)
}

/**
* @deprecated since 5.3
* @deprecated since Symfony 5.3
*/
public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
{
Expand Down
F438
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function onCheckPassport(CheckPassportEvent $event)
} else {
throw new LogicException('Using the "query_string" config without using a "search_dn" and a "search_password" is not supported.');
}
// @deprecated since 5.3, change to $user->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $user->getUserIdentifier() in 6.0
$username = $ldap->escape(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername(), '', LdapInterface::ESCAPE_FILTER);
$query = str_replace('{username}', $username, $ldapBadge->getQueryString());
$result = $ldap->query($ldapBadge->getDnString(), $query)->execute();
Expand All @@ -93,7 +93,7 @@ public function onCheckPassport(CheckPassportEvent $event)

$dn = $result[0]->getDn();
} else {
// @deprecated since 5.3, change to $user->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $user->getUserIdentifier() in 6.0
$username = $ldap->escape(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername(), '', LdapInterface::ESCAPE_DN);
$dn = str_replace('{username}', $username, $ldapBadge->getDnString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function authenticate(TokenInterface $token)
$this->eventDispatcher->dispatch(new AuthenticationSuccessEvent($result), AuthenticationEvents::AUTHENTICATION_SUCCESS);
}

// @deprecated since 5.3
// @deprecated since Symfony 5.3
if ($user = $result->getUser() instanceof UserInterface && !method_exists($result->getUser(), 'getUserIdentifier')) {
trigger_deprecation('symfony/security-core', '5.3', 'Not implementing method "getUserIdentifier(): string" in user class "%s" is deprecated. This method will replace "getUsername()" in Symfony 6.0.', get_debug_type($result->getUser()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected function retrieveUser(string $userIdentifier, UsernamePasswordToken $t
}

try {
// @deprecated since 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
if (method_exists($this->userProvider, 'loadUserByIdentifier')) {
$user = $this->userProvider->loadUserByIdentifier($userIdentifier);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function retrieveUser(string $userIdentifier, UsernamePasswordToken $t
throw new UserNotFoundException('User identifier can not be null.');
}

// @deprecated since 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
if (method_exists($this->userProvider, 'loadUserByIdentifier')) {
return $this->userProvider->loadUserByIdentifier($userIdentifier);
} else {
Expand All @@ -85,7 +85,7 @@ protected function retrieveUser(string $userIdentifier, UsernamePasswordToken $t
*/
protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
{
// @deprecated since 5.3, change to $token->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $token->getUserIdentifier() in 6.0
$userIdentifier = method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername();
$password = $token->getCredentials();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function authenticate(TokenInterface $token)
}

$userIdentifier = method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername();
// @deprecated since 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
if (method_exists($this->userProvider, 'loadUserByIdentifier')) {
$user = $this->userProvider->loadUserByIdentifier($userIdentifier);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getUserIdentifier(): string
}

if ($this->user instanceof UserInterface) {
// @deprecated since 5.3, change to $user->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $user->getUserIdentifier() in 6.0
return method_exists($this->user, 'getUserIdentifier') ? $this->user->getUserIdentifier() : $this->user->getUsername();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct($user, $credentials, string $firewallName, array $ro
*
* @return string The provider key
*
* @deprecated since 5.2, use getFirewallName() instead
* @deprecated since Symfony 5.2, use getFirewallName() instead
*/
public function getProviderKey()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function setAuthenticated(bool $authenticated)
*
* @return string The provider secret
*
* @deprecated since 5.2, use getFirewallName() instead
* @deprecated since Symfony 5.2, use getFirewallName() instead
*/
public function getProviderKey()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function setToken(TokenInterface $token = null)
// ensure any initializer is called
$this->getToken();

// @deprecated since 5.3
// @deprecated since Symfony 5.3
if (!method_exists($token, 'getUserIdentifier')) {
trigger_deprecation('symfony/security-core', '5.3', 'Not implementing method "getUserIdentifier(): string" in token class "%s" is deprecated. This method will replace "getUsername()" in Symfony 6.0.', get_debug_type($token));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getCredentials()
*
* @return string The provider key
*
* @deprecated since 5.2, use getFirewallName() instead
* @deprecated since Symfony 5.2, use getFirewallName() instead
*/
public function getProviderKey()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function loadUserByIdentifier(string $userIdentifier): UserInterface
{
foreach ($this->providers as $provider) {
try {
// @deprecated since 5.3, change to $provider->loadUserByIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $provider->loadUserByIdentifier() in 6.0
if (!method_exists($provider, 'loadUserByIdentifier')) {
trigger_deprecation('symfony/security-core', '5.3', 'Not implementing method "loadUserByIdentifier()" in user provider "%s" is deprecated. This method will replace "loadUserByUsername()" in Symfony 6.0.', get_debug_type($provider));

Expand Down Expand Up @@ -101,7 +101,7 @@ public function refreshUser(UserInterface $user)
}

if ($supportedUserFound) {
// @deprecated since 5.3, change to $user->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $user->getUserIdentifier() in 6.0
$username = method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername();
$e = new UserNotFoundException(sprintf('There is no user with name "%s".', $username));
$e->setUserIdentifier($username);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(array $users = [])
*/
public function createUser(UserInterface $user)
{
// @deprecated since 5.3, change to $user->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $user->getUserIdentifier() in 6.0
$userIdentifier = strtolower(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername());
if (isset($this->users[$userIdentifier])) {
throw new \LogicException('Another user with the same username already exists.');
Expand All @@ -74,7 +74,7 @@ public function loadUserByIdentifier(string $identifier): UserInterface
{
$user = $this->getUser($identifier);

// @deprecated since 5.3, change to $user->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $user->getUserIdentifier() in 6.0
return new InMemoryUser(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername(), $user->getPassword(), $user->getRoles(), $user->isEnabled());
}

Expand All @@ -87,7 +87,7 @@ public function refreshUser(UserInterface $user)
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
}

// @deprecated since 5.3, change to $user->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $user->getUserIdentifier() in 6.0
$storedUser = $this->getUser(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername());
$userIdentifier = method_exists($storedUser, 'getUserIdentifier') ? $storedUser->getUserIdentifier() : $storedUser->getUsername();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private function authenticateViaGuard(AuthenticatorInterface $guardAuthenticator

if (null === $user) {
$e = new UserNotFoundException(sprintf('Null returned from "%s::getUser()".', get_debug_type($guardAuthenticator)));
// @deprecated since 5.3, change to $token->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $token->getUserIdentifier() in 6.0
$e->setUserIdentifier(method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername());

throw $e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct(iterable $authenticators, TokenStorageInterface $tok
public function authenticateUser(UserInterface $user, AuthenticatorInterface $authenticator, Request $request, array $badges = []): ?Response
{
// create an authenticated token for the User
// @deprecated since 5.3, change to $user->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $user->getUserIdentifier() in 6.0
$token = $authenticator->createAuthenticatedToken($passport = new SelfValidatingPassport(new UserBadge(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername(), function () use ($user) { return $user; }), $badges), $this->firewallName);

// announce the authenticated token
Expand Down Expand Up @@ -229,7 +229,7 @@ private function executeAuthenticator(AuthenticatorInterface $authenticator, Req

private function handleAuthenticationSuccess(TokenInterface $authenticatedToken, PassportInterface $passport, Request $request, AuthenticatorInterface $authenticator): ?Response
{
// @deprecated since 5.3
// @deprecated since Symfony 5.3
$user = $authenticatedToken->getUser();
if ($user instanceof UserInterface && !method_exists($user, 'getUserIdentifier')) {
trigger_deprecation('symfony/security-core', '5.3', 'Not implementing method "getUserIdentifier(): string" in user class "%s" is deprecated. This method will replace "getUsername()" in Symfony 6.0.', get_debug_type($authenticatedToken->getUser()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandle

protected $httpUtils;
protected $options;
/** @deprecated since 5.2, use $firewallName instead */
/** @deprecated since Symfony 5.2, use $firewallName instead */
protected $providerKey;
protected $firewallName;
protected $defaultOptions = [
Expand Down Expand Up @@ -78,7 +78,7 @@ public function setOptions(array $options)
*
* @return string
*
* @deprecated since 5.2, use getFirewallName() instead
* @deprecated since Symfony 5.2, use getFirewallName() instead
*/
public function getProviderKey()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function supports(Request $request): ?bool

public function authenticate(Request $request): PassportInterface
{
// @deprecated since 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
$method = 'loadUserByIdentifier';
if (!method_exists($this->userProvider, 'loadUserByIdentifier')) {
trigger_deprecation('symfony/security-core', '5.3', 'Not implementing method "loadUserByIdentifier()" in user provider "%s" is deprecated. This method will replace "loadUserByUsername()" in Symfony 6.0.', get_debug_type($this->userProvider));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function authenticate(Request $request): PassportInterface
{
$credentials = $this->getCredentials($request);

// @deprecated since 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
$method = 'loadUserByIdentifier';
if (!method_exists($this->userProvider, 'loadUserByIdentifier')) {
trigger_deprecation('symfony/security-core', '5.3', 'Not implementing method "loadUserByIdentifier()" in user provider "%s" is deprecated. This method will replace "loadUserByUsername()" in Symfony 6.0.', get_debug_type($this->userProvider));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function authenticate(Request $request): PassportInterface
$username = $request->headers->get('PHP_AUTH_USER');
$password = $request->headers->get('PHP_AUTH_PW', '');

// @deprecated since 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
$method = 'loadUserByIdentifier';
if (!method_exists($this->userProvider, 'loadUserByIdentifier')) {
trigger_deprecation('symfony/security-core', '5.3', 'Not implementing method "loadUserByIdentifier()" in user provider "%s" is deprecated. This method will replace "loadUserByUsername()" in Symfony 6.0.', get_debug_type($this->userProvider));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function authenticate(Request $request): PassportInterface
throw $e;
}

// @deprecated since 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
$method = 'loadUserByIdentifier';
if (!method_exists($this->userProvider, 'loadUserByIdentifier')) {
trigger_deprecation('symfony/security-core', '5.3', 'Not implementing method "loadUserByIdentifier()" in user provider "%s" is deprecated. This method will replace "loadUserByUsername()" in Symfony 6.0.', get_debug_type($this->userProvider));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function checkPassport(CheckPassportEvent $event): void
return;
}

// @deprecated since 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $this->userProvider->loadUserByIdentifier() in 6.0
if (method_exists($this->userProvider, 'loadUserByIdentifier')) {
$badge->setUserLoader([$this->userProvider, 'loadUserByIdentifier']);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private function onFailure(Request $request, AuthenticationException $failed): R
private function onSuccess(Request $request, TokenInterface $token): Response
{
if (null !== $this->logger) {
// @deprecated since 5.3, change to $token->getUserIdentifier() in 6.0
// @deprecated since Symfony 5.3, change to $token->getUserIdentifier() in 6.0
$this->logger->info('User has been authenticated successfully.', ['username' => method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername()]);
}

Expand Down
Loading
0