Skip to content

Commit ff7e2c0

Browse files
Merge branch '5.4' into 6.3
* 5.4: Fix implicitly-required parameters List CS fix in .git-blame-ignore-revs Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value [Messenger][AmazonSqs] Allow async-aws/sqs version 2
2 parents c254ce6 + 3cbacef commit ff7e2c0

20 files changed

+145
-21
lines changed

Authentication/AuthenticationTrustResolver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
*/
2222
class AuthenticationTrustResolver implements AuthenticationTrustResolverInterface
2323
{
24-
public function isAuthenticated(TokenInterface $token = null): bool
24+
public function isAuthenticated(?TokenInterface $token = null): bool
2525
{
2626
return $token && $token->getUser();
2727
}
2828

29-
public function isRememberMe(TokenInterface $token = null): bool
29+
public function isRememberMe(?TokenInterface $token = null): bool
3030
{
3131
return $token && $token instanceof RememberMeToken;
3232
}
3333

34-
public function isFullFledged(TokenInterface $token = null): bool
34+
public function isFullFledged(?TokenInterface $token = null): bool
3535
{
3636
return $this->isAuthenticated($token) && !$this->isRememberMe($token);
3737
}

Authentication/AuthenticationTrustResolverInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ interface AuthenticationTrustResolverInterface
2323
/**
2424
* Resolves whether the passed token implementation is authenticated.
2525
*/
26-
public function isAuthenticated(TokenInterface $token = null): bool;
26+
public function isAuthenticated(?TokenInterface $token = null): bool;
2727

2828
/**
2929
* Resolves whether the passed token implementation is authenticated
3030
* using remember-me capabilities.
3131
*/
32-
public function isRememberMe(TokenInterface $token = null): bool;
32+
public function isRememberMe(?TokenInterface $token = null): bool;
3333

3434
/**
3535
* Resolves whether the passed token implementation is fully authenticated.
3636
*/
37-
public function isFullFledged(TokenInterface $token = null): bool;
37+
public function isFullFledged(?TokenInterface $token = null): bool;
3838
}

Authentication/Token/Storage/TokenStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getToken(): ?TokenInterface
4040
/**
4141
* @return void
4242
*/
43-
public function setToken(TokenInterface $token = null)
43+
public function setToken(?TokenInterface $token = null)
4444
{
4545
if (1 > \func_num_args()) {
4646
trigger_deprecation('symfony/security-core', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);

Authentication/Token/Storage/UsageTrackingTokenStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function getToken(): ?TokenInterface
4444
return $this->storage->getToken();
4545
}
4646

47-
public function setToken(TokenInterface $token = null): void
47+
public function setToken(?TokenInterface $token = null): void
4848
{
4949
$this->storage->setToken($token);
5050

Authentication/Token/SwitchUserToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class SwitchUserToken extends UsernamePasswordToken
2929
*
3030
* @throws \InvalidArgumentException
3131
*/
32-
public function __construct(UserInterface $user, string $firewallName, array $roles, TokenInterface $originalToken, string $originatedFromUri = null)
32+
public function __construct(UserInterface $user, string $firewallName, array $roles, TokenInterface $originalToken, ?string $originatedFromUri = null)
3333
{
3434
parent::__construct($user, $firewallName, $roles);
3535

Authorization/AccessDecisionManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final class AccessDecisionManager implements AccessDecisionManagerInterface
4040
/**
4141
* @param iterable<mixed, VoterInterface> $voters An array or an iterator of VoterInterface instances
4242
*/
43-
public function __construct(iterable $voters = [], AccessDecisionStrategyInterface $strategy = null)
43+
public function __construct(iterable $voters = [], ?AccessDecisionStrategyInterface $strategy = null)
4444
{
4545
$this->voters = $voters;
4646
$this->strategy = $strategy ?? new AffirmativeStrategy();

Authorization/ExpressionLanguage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class_exists(ExpressionLanguageProvider::class);
2929
*/
3030
class ExpressionLanguage extends BaseExpressionLanguage
3131
{
32-
public function __construct(CacheItemPoolInterface $cache = null, array $providers = [])
32+
public function __construct(?CacheItemPoolInterface $cache = null, array $providers = [])
3333
{
3434
// prepend the default provider to let users override it easily
3535
array_unshift($providers, new ExpressionLanguageProvider());

Authorization/Voter/ExpressionVoter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ExpressionVoter implements CacheableVoterInterface
3131
private AuthorizationCheckerInterface $authChecker;
3232
private ?RoleHierarchyInterface $roleHierarchy;
3333

34-
public function __construct(ExpressionLanguage $expressionLanguage, AuthenticationTrustResolverInterface $trustResolver, AuthorizationCheckerInterface $authChecker, RoleHierarchyInterface $roleHierarchy = null)
34+
public function __construct(ExpressionLanguage $expressionLanguage, AuthenticationTrustResolverInterface $trustResolver, AuthorizationCheckerInterface $authChecker, ?RoleHierarchyInterface $roleHierarchy = null)
3535
{
3636
$this->expressionLanguage = $expressionLanguage;
3737
$this->trustResolver = $trustResolver;

Encoder/NativePasswordEncoder.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Security\Core\Encoder;
13+
14+
use Symfony\Component\PasswordHasher\Hasher\NativePasswordHasher;
15+
16+
trigger_deprecation('symfony/security-core', '5.3', 'The "%s" class is deprecated, use "%s" instead.', NativePasswordEncoder::class, NativePasswordHasher::class);
17+
18+
/**
19+
* Hashes passwords using password_hash().
20+
*
21+
* @author Elnur Abdurrakhimov <elnur@elnur.pro>
22+
* @author Terje Bråten <terje@braten.be>
23+
* @author Nicolas Grekas <p@tchwork.com>
24+
*
25+
* @deprecated since Symfony 5.3, use {@link NativePasswordHasher} instead
26+
*/
27+
final class NativePasswordEncoder implements PasswordEncoderInterface, SelfSaltingEncoderInterface
28+
{
29+
use LegacyEncoderTrait;
30+
31+
/**
32+
* @param string|null $algo An algorithm supported by password_hash() or null to use the stronger available algorithm
33+
*/
34+
public function __construct(?int $opsLimit = null, ?int $memLimit = null, ?int $cost = null, ?string $algo = null)
35+
{
36+
$this->hasher = new NativePasswordHasher($opsLimit, $memLimit, $cost, $algo);
37+
}
38+
}

Encoder/PasswordHasherAdapter.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Security\Core\Encoder;
13+
14+
use Symfony\Component\PasswordHasher\LegacyPasswordHasherInterface;
15+
16+
/**
17+
* Forward compatibility for new new PasswordHasher component.
18+
*
19+
* @author Alexander M. Turek <me@derrabus.de>
20+
*
21+
* @internal To be removed in Symfony 6
22+
*/
23+
final class PasswordHasherAdapter implements LegacyPasswordHasherInterface
24+
{
25+
private $passwordEncoder;
26+
27+
public function __construct(PasswordEncoderInterface $passwordEncoder)
28+
{
29+
$this->passwordEncoder = $passwordEncoder;
30+
}
31+
32+
public function hash(string $plainPassword, ?string $salt = null): string
33+
{
34+
return $this->passwordEncoder->encodePassword($plainPassword, $salt);
35+
}
36+
37+
public function verify(string $hashedPassword, string $plainPassword, ?string $salt = null): bool
38+
{
39+
return $this->passwordEncoder->isPasswordValid($hashedPassword, $plainPassword, $salt);
40+
}
41+
42+
public function needsRehash(string $hashedPassword): bool
43+
{
44+
return $this->passwordEncoder->needsRehash($hashedPassword);
45+
}
46+
}

0 commit comments

Comments
 (0)