Skip to content

Commit 3c7de56

Browse files
fafiebignicolas-grekas
authored andcommitted
[Lock] 7.0 remove deprecations in Lock Component
1 parent bf58846 commit 3c7de56

File tree

7 files changed

+8
-159
lines changed

7 files changed

+8
-159
lines changed

Authentication/Token/Storage/TokenStorage.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,8 @@ public function getToken(): ?TokenInterface
4040
/**
4141
* @return void
4242
*/
43-
public function setToken(TokenInterface $token = null)
43+
public function setToken(?TokenInterface $token)
4444
{
45-
if (1 > \func_num_args()) {
46-
trigger_deprecation('symfony/security-core', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
47-
}
48-
4945
if ($token) {
5046
// ensure any initializer is called
5147
$this->getToken();

Authorization/AuthorizationChecker.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,10 @@
2424
*/
2525
class AuthorizationChecker implements AuthorizationCheckerInterface
2626
{
27-
private TokenStorageInterface $tokenStorage;
28-
private AccessDecisionManagerInterface $accessDecisionManager;
29-
30-
public function __construct(TokenStorageInterface $tokenStorage, AccessDecisionManagerInterface $accessDecisionManager, bool $exceptionOnNoToken = false)
31-
{
32-
if ($exceptionOnNoToken) {
33-
throw new \LogicException(sprintf('Argument $exceptionOnNoToken of "%s()" must be set to "false".', __METHOD__));
34-
}
35-
36-
$this->tokenStorage = $tokenStorage;
37-
$this->accessDecisionManager = $accessDecisionManager;
27+
public function __construct(
28+
private TokenStorageInterface $tokenStorage,
29+
private AccessDecisionManagerInterface $accessDecisionManager,
30+
) {
3831
}
3932

4033
final public function isGranted(mixed $attribute, mixed $subject = null): bool

Security.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,8 @@
2424
*/
2525
class Security implements AuthorizationCheckerInterface
2626
{
27-
/**
28-
* @deprecated since Symfony 6.2, use \Symfony\Bundle\SecurityBundle\Security::ACCESS_DENIED_ERROR instead
29-
*/
3027
public const ACCESS_DENIED_ERROR = '_security.403_error';
31-
32-
/**
33-
* @deprecated since Symfony 6.2, use \Symfony\Bundle\SecurityBundle\Security::AUTHENTICATION_ERROR instead
34-
*/
3528
public const AUTHENTICATION_ERROR = '_security.last_error';
36-
37-
/**
38-
* @deprecated since Symfony 6.2, use \Symfony\Bundle\SecurityBundle\Security::LAST_USERNAME instead
39-
*/
4029
public const LAST_USERNAME = '_security.last_username';
4130

4231
/**

Tests/Authentication/Token/Storage/TokenStorageTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,12 @@
1212
namespace Symfony\Component\Security\Core\Tests\Authentication\Token\Storage;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1615
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
1716
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
1817
use Symfony\Component\Security\Core\User\InMemoryUser;
1918

2019
class TokenStorageTest extends TestCase
2120
{
22-
use ExpectDeprecationTrait;
23-
24-
/**
25-
* @group legacy
26-
*/
27-
public function testGetSetTokenLegacy()
28-
{
29-
$tokenStorage = new TokenStorage();
30-
$token = new UsernamePasswordToken(new InMemoryUser('username', 'password'), 'provider');
31-
$tokenStorage->setToken($token);
32-
$this->assertSame($token, $tokenStorage->getToken());
33-
34-
$this->expectDeprecation('Since symfony/security-core 6.2: Calling "Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage::setToken()" without any arguments is deprecated, pass null explicitly instead.');
35-
36-
$tokenStorage->setToken();
37-
$this->assertNull($tokenStorage->getToken());
38-
}
39-
4021
public function testGetSetToken()
4122
{
4223
$tokenStorage = new TokenStorage();

Tests/SecurityTest.php

Lines changed: 0 additions & 98 deletions
This file was deleted.

User/ChainUserProvider.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ public function getProviders(): array
4646
return $this->providers;
4747
}
4848

49-
/**
50-
* @internal for compatibility with Symfony 5.4
51-
*/
52-
public function loadUserByUsername(string $username): UserInterface
53-
{
54-
return $this->loadUserByIdentifier($username);
55-
}
56-
5749
public function loadUserByIdentifier(string $identifier): UserInterface
5850
{
5951
foreach ($this->providers as $provider) {

User/InMemoryUserProvider.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,11 @@ public function __construct(array $users = [])
5151
* Adds a new User to the provider.
5252
*
5353
* @return void
54-
*
55-
* @throws \LogicException
5654
*/
5755
public function createUser(UserInterface $user)
5856
{
5957
if (!$user instanceof InMemoryUser) {
60-
trigger_deprecation('symfony/security-core', '6.3', 'Passing users that are not instance of "%s" to "%s" is deprecated, "%s" given.', InMemoryUser::class, __METHOD__, get_debug_type($user));
58+
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
6159
}
6260

6361
$userIdentifier = strtolower($user->getUserIdentifier());
@@ -93,13 +91,11 @@ public function supportsClass(string $class): bool
9391
}
9492

9593
/**
96-
* Returns the user by given username.
97-
*
98-
* @return InMemoryUser change return type on 7.0
94+
* Returns the user by given user.
9995
*
10096
* @throws UserNotFoundException if user whose given username does not exist
10197
*/
102-
private function getUser(string $username): UserInterface
98+
private function getUser(string $username): InMemoryUser
10399
{
104100
if (!isset($this->users[strtolower($username)])) {
105101
$ex = new UserNotFoundException(sprintf('Username "%s" does not exist.', $username));

0 commit comments

Comments
 (0)