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+
}

Encoder/SodiumPasswordEncoder.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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\SodiumPasswordHasher;
15+
16+
trigger_deprecation('symfony/security-core', '5.3', 'The "%s" class is deprecated, use "%s" instead.', SodiumPasswordEncoder::class, SodiumPasswordHasher::class);
17+
18+
/**
19+
* Hashes passwords using libsodium.
20+
*
21+
* @author Robin Chalas <robin.chalas@gmail.com>
22+
* @author Zan Baldwin <hello@zanbaldwin.com>
23+
* @author Dominik Müller <dominik.mueller@jkweb.ch>
24+
*
25+
* @deprecated since Symfony 5.3, use {@link SodiumPasswordHasher} instead
26+
*/
27+
final class SodiumPasswordEncoder implements PasswordEncoderInterface, SelfSaltingEncoderInterface
28+
{
29+
use LegacyEncoderTrait;
30+
31+
public function __construct(?int $opsLimit = null, ?int $memLimit = null)
32+
{
33+
$this->hasher = new SodiumPasswordHasher($opsLimit, $memLimit);
34+
}
35+
36+
public static function isSupported(): bool
37+
{
38+
return SodiumPasswordHasher::isSupported();
39+
}
40+
}

Exception/AccessDeniedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AccessDeniedException extends RuntimeException
2424
private array $attributes = [];
2525
private mixed $subject = null;
2626

27-
public function __construct(string $message = 'Access Denied.', \Throwable $previous = null, int $code = 403)
27+
public function __construct(string $message = 'Access Denied.', ?\Throwable $previous = null, int $code = 403)
2828
{
2929
parent::__construct($message, $code, $previous);
3030
}

Exception/AuthenticationException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AuthenticationException extends RuntimeException
2828

2929
private ?TokenInterface $token = null;
3030

31-
public function __construct(string $message = '', int $code = 0, \Throwable $previous = null)
31+
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null)
3232
{
3333
unset($this->serialized);
3434
parent::__construct($message, $code, $previous);

Exception/CustomUserMessageAccountStatusException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CustomUserMessageAccountStatusException extends AccountStatusException
2626
private string $messageKey;
2727
private array $messageData = [];
2828

29-
public function __construct(string $message = '', array $messageData = [], int $code = 0, \Throwable $previous = null)
29+
public function __construct(string $message = '', array $messageData = [], int $code = 0, ?\Throwable $previous = null)
3030
{
3131
parent::__construct($message, $code, $previous);
3232

Exception/CustomUserMessageAuthenticationException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CustomUserMessageAuthenticationException extends AuthenticationException
2525
private string $messageKey;
2626
private array $messageData = [];
2727

28-
public function __construct(string $message = '', array $messageData = [], int $code = 0, \Throwable $previous = null)
28+
public function __construct(string $message = '', array $messageData = [], int $code = 0, ?\Throwable $previous = null)
2929
{
3030
parent::__construct($message, $code, $previous);
3131

Exception/LogoutException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class LogoutException extends RuntimeException
2020
{
21-
public function __construct(string $message = 'Logout Exception', \Throwable $previous = null)
21+
public function __construct(string $message = 'Logout Exception', ?\Throwable $previous = null)
2222
{
2323
parent::__construct($message, 403, $previous);
2424
}

Exception/TooManyLoginAttemptsAuthenticationException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TooManyLoginAttemptsAuthenticationException extends AuthenticationExceptio
2121
{
2222
private ?int $threshold;
2323

24-
public function __construct(int $threshold = null)
24+
public function __construct(?int $threshold = null)
2525
{
2626
$this->threshold = $threshold;
2727
}

Signature/SignatureHasher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SignatureHasher
3535
* @param ExpiredSignatureStorage|null $expiredSignaturesStorage If provided, secures a sequence of hashes that are expired
3636
* @param int|null $maxUses Used together with $expiredSignatureStorage to allow a maximum usage of a hash
3737
*/
38-
public function __construct(PropertyAccessorInterface $propertyAccessor, array $signatureProperties, #[\SensitiveParameter] string $secret, ExpiredSignatureStorage $expiredSignaturesStorage = null, int $maxUses = null)
38+
public function __construct(PropertyAccessorInterface $propertyAccessor, array $signatureProperties, #[\SensitiveParameter] string $secret, ?ExpiredSignatureStorage $expiredSignaturesStorage = null, ?int $maxUses = null)
3939
{
4040
$this->propertyAccessor = $propertyAccessor;
4141
$this->signatureProperties = $signatureProperties;

Tests/Authentication/Token/AbstractTokenTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class ConcreteToken extends AbstractToken
9898
{
9999
private $credentials = 'credentials_value';
100100

101-
public function __construct(array $roles = [], UserInterface $user = null)
101+
public function __construct(array $roles = [], ?UserInterface $user = null)
102102
{
103103
parent::__construct($roles);
104104

Validator/Constraints/UserPassword.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class UserPassword extends Constraint
2929
public $message = 'This value should be the user\'s current password.';
3030
public $service = 'security.validator.user_password';
3131

32-
public function __construct(array $options = null, string $message = null, string $service = null, array $groups = null, mixed $payload = null)
32+
public function __construct(?array $options = null, ?string $message = null, ?string $service = null, ?array $groups = null, mixed $payload = null)
3333
{
3434
parent::__construct($options, $groups, $payload);
3535

0 commit comments

Comments
 (0)