diff --git a/.gitattributes b/.gitattributes
index 84c7add0..14c3c359 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,4 +1,3 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
-/.gitattributes export-ignore
-/.gitignore export-ignore
+/.git* export-ignore
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 00000000..4689c4da
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,8 @@
+Please do not submit any Pull Requests here. They will be closed.
+---
+
+Please submit your PR here instead:
+https://github.com/symfony/symfony
+
+This repository is what we call a "subtree split": a read-only subset of that main repository.
+We're looking forward to your PR there!
diff --git a/.github/workflows/close-pull-request.yml b/.github/workflows/close-pull-request.yml
new file mode 100644
index 00000000..e55b4781
--- /dev/null
+++ b/.github/workflows/close-pull-request.yml
@@ -0,0 +1,20 @@
+name: Close Pull Request
+
+on:
+ pull_request_target:
+ types: [opened]
+
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: superbrothers/close-pull-request@v3
+ with:
+ comment: |
+ Thanks for your Pull Request! We love contributions.
+
+ However, you should instead open your PR on the main repository:
+ https://github.com/symfony/symfony
+
+ This repository is what we call a "subtree split": a read-only subset of that main repository.
+ We're looking forward to your PR there!
diff --git a/Authentication/RememberMe/CacheTokenVerifier.php b/Authentication/RememberMe/CacheTokenVerifier.php
index e4f1362a..3930ac8d 100644
--- a/Authentication/RememberMe/CacheTokenVerifier.php
+++ b/Authentication/RememberMe/CacheTokenVerifier.php
@@ -18,21 +18,17 @@
*/
class CacheTokenVerifier implements TokenVerifierInterface
{
- private CacheItemPoolInterface $cache;
- private int $outdatedTokenTtl;
- private string $cacheKeyPrefix;
-
/**
* @param int $outdatedTokenTtl How long the outdated token should still be considered valid. Defaults
* to 60, which matches how often the PersistentRememberMeHandler will at
* most refresh tokens. Increasing to more than that is not recommended,
* but you may use a lower value.
*/
- public function __construct(CacheItemPoolInterface $cache, int $outdatedTokenTtl = 60, string $cacheKeyPrefix = 'rememberme-stale-')
- {
- $this->cache = $cache;
- $this->outdatedTokenTtl = $outdatedTokenTtl;
- $this->cacheKeyPrefix = $cacheKeyPrefix;
+ public function __construct(
+ private CacheItemPoolInterface $cache,
+ private int $outdatedTokenTtl = 60,
+ private string $cacheKeyPrefix = 'rememberme-stale-',
+ ) {
}
public function verifyToken(PersistentTokenInterface $token, #[\SensitiveParameter] string $tokenValue): bool
diff --git a/Authentication/RememberMe/PersistentToken.php b/Authentication/RememberMe/PersistentToken.php
index f473ccb7..0f391c23 100644
--- a/Authentication/RememberMe/PersistentToken.php
+++ b/Authentication/RememberMe/PersistentToken.php
@@ -18,31 +18,28 @@
*/
final class PersistentToken implements PersistentTokenInterface
{
- private string $class;
- private string $userIdentifier;
- private string $series;
- private string $tokenValue;
private \DateTimeImmutable $lastUsed;
- public function __construct(string $class, string $userIdentifier, string $series, #[\SensitiveParameter] string $tokenValue, \DateTimeInterface $lastUsed)
- {
- if (empty($class)) {
+ public function __construct(
+ private string $class,
+ private string $userIdentifier,
+ private string $series,
+ #[\SensitiveParameter] private string $tokenValue,
+ \DateTimeInterface $lastUsed,
+ ) {
+ if (!$class) {
throw new \InvalidArgumentException('$class must not be empty.');
}
if ('' === $userIdentifier) {
throw new \InvalidArgumentException('$userIdentifier must not be empty.');
}
- if (empty($series)) {
+ if (!$series) {
throw new \InvalidArgumentException('$series must not be empty.');
}
- if (empty($tokenValue)) {
+ if (!$tokenValue) {
throw new \InvalidArgumentException('$tokenValue must not be empty.');
}
- $this->class = $class;
- $this->userIdentifier = $userIdentifier;
- $this->series = $series;
- $this->tokenValue = $tokenValue;
$this->lastUsed = \DateTimeImmutable::createFromInterface($lastUsed);
}
diff --git a/Authentication/Token/AbstractToken.php b/Authentication/Token/AbstractToken.php
index 36d64766..67d992ce 100644
--- a/Authentication/Token/AbstractToken.php
+++ b/Authentication/Token/AbstractToken.php
@@ -125,7 +125,7 @@ public function hasAttribute(string $name): bool
public function getAttribute(string $name): mixed
{
if (!\array_key_exists($name, $this->attributes)) {
- throw new \InvalidArgumentException(sprintf('This token has no "%s" attribute.', $name));
+ throw new \InvalidArgumentException(\sprintf('This token has no "%s" attribute.', $name));
}
return $this->attributes[$name];
@@ -146,7 +146,7 @@ public function __toString(): string
$roles[] = $role;
}
- return sprintf('%s(user="%s", roles="%s")', $class, $this->getUserIdentifier(), implode(', ', $roles));
+ return \sprintf('%s(user="%s", roles="%s")', $class, $this->getUserIdentifier(), implode(', ', $roles));
}
/**
diff --git a/Authentication/Token/PreAuthenticatedToken.php b/Authentication/Token/PreAuthenticatedToken.php
index a216d4c1..5c092404 100644
--- a/Authentication/Token/PreAuthenticatedToken.php
+++ b/Authentication/Token/PreAuthenticatedToken.php
@@ -20,13 +20,14 @@
*/
class PreAuthenticatedToken extends AbstractToken
{
- private string $firewallName;
-
/**
* @param string[] $roles
*/
- public function __construct(UserInterface $user, string $firewallName, array $roles = [])
- {
+ public function __construct(
+ UserInterface $user,
+ private string $firewallName,
+ array $roles = [],
+ ) {
parent::__construct($roles);
if ('' === $firewallName) {
@@ -34,7 +35,6 @@ public function __construct(UserInterface $user, string $firewallName, array $ro
}
$this->setUser($user);
- $this->firewallName = $firewallName;
}
public function getFirewallName(): string
diff --git a/Authentication/Token/RememberMeToken.php b/Authentication/Token/RememberMeToken.php
index ad218f1b..dfbe20ec 100644
--- a/Authentication/Token/RememberMeToken.php
+++ b/Authentication/Token/RememberMeToken.php
@@ -21,29 +21,26 @@
*/
class RememberMeToken extends AbstractToken
{
- private string $secret;
- private string $firewallName;
+ private ?string $secret = null;
/**
- * @param string $secret A secret used to make sure the token is created by the app and not by a malicious client
- *
* @throws \InvalidArgumentException
*/
- public function __construct(UserInterface $user, string $firewallName, #[\SensitiveParameter] string $secret)
- {
+ public function __construct(
+ UserInterface $user,
+ private string $firewallName,
+ ) {
parent::__construct($user->getRoles());
- if (!$secret) {
- throw new InvalidArgumentException('A non-empty secret is required.');
+ if (\func_num_args() > 2) {
+ trigger_deprecation('symfony/security-core', '7.2', 'The "$secret" argument of "%s()" is deprecated.', __METHOD__);
+ $this->secret = func_get_arg(2);
}
if (!$firewallName) {
throw new InvalidArgumentException('$firewallName must not be empty.');
}
- $this->firewallName = $firewallName;
- $this->secret = $secret;
-
$this->setUser($user);
}
@@ -52,13 +49,19 @@ public function getFirewallName(): string
return $this->firewallName;
}
+ /**
+ * @deprecated since Symfony 7.2
+ */
public function getSecret(): string
{
- return $this->secret;
+ trigger_deprecation('symfony/security-core', '7.2', 'The "%s()" method is deprecated.', __METHOD__);
+
+ return $this->secret ??= base64_encode(random_bytes(8));
}
public function __serialize(): array
{
+ // $this->firewallName should be kept at index 1 for compatibility with payloads generated before Symfony 8
return [$this->secret, $this->firewallName, parent::__serialize()];
}
diff --git a/Authentication/Token/Storage/UsageTrackingTokenStorage.php b/Authentication/Token/Storage/UsageTrackingTokenStorage.php
index 8a4069e7..4255491d 100644
--- a/Authentication/Token/Storage/UsageTrackingTokenStorage.php
+++ b/Authentication/Token/Storage/UsageTrackingTokenStorage.php
@@ -24,14 +24,12 @@
*/
final class UsageTrackingTokenStorage implements TokenStorageInterface, ServiceSubscriberInterface
{
- private TokenStorageInterface $storage;
- private ContainerInterface $container;
private bool $enableUsageTracking = false;
- public function __construct(TokenStorageInterface $storage, ContainerInterface $container)
- {
- $this->storage = $storage;
- $this->container = $container;
+ public function __construct(
+ private TokenStorageInterface $storage,
+ private ContainerInterface $container,
+ ) {
}
public function getToken(): ?TokenInterface
diff --git a/Authentication/Token/SwitchUserToken.php b/Authentication/Token/SwitchUserToken.php
index fb632a61..c4e69766 100644
--- a/Authentication/Token/SwitchUserToken.php
+++ b/Authentication/Token/SwitchUserToken.php
@@ -20,7 +20,6 @@
*/
class SwitchUserToken extends UsernamePasswordToken
{
- private TokenInterface $originalToken;
private ?string $originatedFromUri = null;
/**
@@ -29,11 +28,15 @@ class SwitchUserToken extends UsernamePasswordToken
*
* @throws \InvalidArgumentException
*/
- public function __construct(UserInterface $user, string $firewallName, array $roles, TokenInterface $originalToken, ?string $originatedFromUri = null)
- {
+ public function __construct(
+ UserInterface $user,
+ string $firewallName,
+ array $roles,
+ private TokenInterface $originalToken,
+ ?string $originatedFromUri = null,
+ ) {
parent::__construct($user, $firewallName, $roles);
- $this->originalToken = $originalToken;
$this->originatedFromUri = $originatedFromUri;
}
diff --git a/Authentication/Token/UsernamePasswordToken.php b/Authentication/Token/UsernamePasswordToken.php
index 74e24a21..40beb003 100644
--- a/Authentication/Token/UsernamePasswordToken.php
+++ b/Authentication/Token/UsernamePasswordToken.php
@@ -20,10 +20,11 @@
*/
class UsernamePasswordToken extends AbstractToken
{
- private string $firewallName;
-
- public function __construct(UserInterface $user, string $firewallName, array $roles = [])
- {
+ public function __construct(
+ UserInterface $user,
+ private string $firewallName,
+ array $roles = [],
+ ) {
parent::__construct($roles);
if ('' === $firewallName) {
@@ -31,7 +32,6 @@ public function __construct(UserInterface $user, string $firewallName, array $ro
}
$this->setUser($user);
- $this->firewallName = $firewallName;
}
public function getFirewallName(): string
diff --git a/Authorization/AccessDecisionManager.php b/Authorization/AccessDecisionManager.php
index 4a56f943..3e42c4bf 100644
--- a/Authorization/AccessDecisionManager.php
+++ b/Authorization/AccessDecisionManager.php
@@ -32,7 +32,6 @@ final class AccessDecisionManager implements AccessDecisionManagerInterface
VoterInterface::ACCESS_ABSTAIN => true,
];
- private iterable $voters;
private array $votersCacheAttributes = [];
private array $votersCacheObject = [];
private AccessDecisionStrategyInterface $strategy;
@@ -40,9 +39,10 @@ final class AccessDecisionManager implements AccessDecisionManagerInterface
/**
* @param iterable $voters An array or an iterator of VoterInterface instances
*/
- public function __construct(iterable $voters = [], ?AccessDecisionStrategyInterface $strategy = null)
- {
- $this->voters = $voters;
+ public function __construct(
+ private iterable $voters = [],
+ ?AccessDecisionStrategyInterface $strategy = null,
+ ) {
$this->strategy = $strategy ?? new AffirmativeStrategy();
}
@@ -53,7 +53,7 @@ public function decide(TokenInterface $token, array $attributes, mixed $object =
{
// Special case for AccessListener, do not remove the right side of the condition before 6.0
if (\count($attributes) > 1 && !$allowMultipleAttributes) {
- throw new InvalidArgumentException(sprintf('Passing more than one Security attribute to "%s()" is not supported.', __METHOD__));
+ throw new InvalidArgumentException(\sprintf('Passing more than one Security attribute to "%s()" is not supported.', __METHOD__));
}
return $this->strategy->decide(
@@ -69,7 +69,7 @@ private function collectResults(TokenInterface $token, array $attributes, mixed
foreach ($this->getVoters($attributes, $object) as $voter) {
$result = $voter->vote($token, $object, $attributes);
if (!\is_int($result) || !(self::VALID_VOTES[$result] ?? false)) {
- throw new \LogicException(sprintf('"%s::vote()" must return one of "%s" constants ("ACCESS_GRANTED", "ACCESS_DENIED" or "ACCESS_ABSTAIN"), "%s" returned.', get_debug_type($voter), VoterInterface::class, var_export($result, true)));
+ throw new \LogicException(\sprintf('"%s::vote()" must return one of "%s" constants ("ACCESS_GRANTED", "ACCESS_DENIED" or "ACCESS_ABSTAIN"), "%s" returned.', get_debug_type($voter), VoterInterface::class, var_export($result, true)));
}
yield $result;
diff --git a/Authorization/ExpressionLanguage.php b/Authorization/ExpressionLanguage.php
index a48d8148..846d2cf6 100644
--- a/Authorization/ExpressionLanguage.php
+++ b/Authorization/ExpressionLanguage.php
@@ -15,7 +15,7 @@
use Symfony\Component\ExpressionLanguage\ExpressionLanguage as BaseExpressionLanguage;
if (!class_exists(BaseExpressionLanguage::class)) {
- throw new \LogicException(sprintf('The "%s" class requires the "ExpressionLanguage" component. Try running "composer require symfony/expression-language".', ExpressionLanguage::class));
+ throw new \LogicException(\sprintf('The "%s" class requires the "ExpressionLanguage" component. Try running "composer require symfony/expression-language".', ExpressionLanguage::class));
} else {
// Help opcache.preload discover always-needed symbols
class_exists(ExpressionLanguageProvider::class);
diff --git a/Authorization/ExpressionLanguageProvider.php b/Authorization/ExpressionLanguageProvider.php
index d3e2dac0..2e558c21 100644
--- a/Authorization/ExpressionLanguageProvider.php
+++ b/Authorization/ExpressionLanguageProvider.php
@@ -28,7 +28,7 @@ public function getFunctions(): array
new ExpressionFunction('is_fully_authenticated', fn () => '$token && $auth_checker->isGranted("IS_AUTHENTICATED_FULLY")', fn (array $variables) => $variables['token'] && $variables['auth_checker']->isGranted('IS_AUTHENTICATED_FULLY')),
- new ExpressionFunction('is_granted', fn ($attributes, $object = 'null') => sprintf('$auth_checker->isGranted(%s, %s)', $attributes, $object), fn (array $variables, $attributes, $object = null) => $variables['auth_checker']->isGranted($attributes, $object)),
+ new ExpressionFunction('is_granted', fn ($attributes, $object = 'null') => \sprintf('$auth_checker->isGranted(%s, %s)', $attributes, $object), fn (array $variables, $attributes, $object = null) => $variables['auth_checker']->isGranted($attributes, $object)),
new ExpressionFunction('is_remember_me', fn () => '$token && $auth_checker->isGranted("IS_REMEMBERED")', fn (array $variables) => $variables['token'] && $variables['auth_checker']->isGranted('IS_REMEMBERED')),
];
diff --git a/Authorization/Strategy/AffirmativeStrategy.php b/Authorization/Strategy/AffirmativeStrategy.php
index ecd74b20..fb316fd3 100644
--- a/Authorization/Strategy/AffirmativeStrategy.php
+++ b/Authorization/Strategy/AffirmativeStrategy.php
@@ -24,11 +24,9 @@
*/
final class AffirmativeStrategy implements AccessDecisionStrategyInterface, \Stringable
{
- private bool $allowIfAllAbstainDecisions;
-
- public function __construct(bool $allowIfAllAbstainDecisions = false)
- {
- $this->allowIfAllAbstainDecisions = $allowIfAllAbstainDecisions;
+ public function __construct(
+ private bool $allowIfAllAbstainDecisions = false,
+ ) {
}
public function decide(\Traversable $results): bool
diff --git a/Authorization/Strategy/ConsensusStrategy.php b/Authorization/Strategy/ConsensusStrategy.php
index 489b3428..bff56513 100644
--- a/Authorization/Strategy/ConsensusStrategy.php
+++ b/Authorization/Strategy/ConsensusStrategy.php
@@ -32,13 +32,10 @@
*/
final class ConsensusStrategy implements AccessDecisionStrategyInterface, \Stringable
{
- private bool $allowIfAllAbstainDecisions;
- private bool $allowIfEqualGrantedDeniedDecisions;
-
- public function __construct(bool $allowIfAllAbstainDecisions = false, bool $allowIfEqualGrantedDeniedDecisions = true)
- {
- $this->allowIfAllAbstainDecisions = $allowIfAllAbstainDecisions;
- $this->allowIfEqualGrantedDeniedDecisions = $allowIfEqualGrantedDeniedDecisions;
+ public function __construct(
+ private bool $allowIfAllAbstainDecisions = false,
+ private bool $allowIfEqualGrantedDeniedDecisions = true,
+ ) {
}
public function decide(\Traversable $results): bool
diff --git a/Authorization/Strategy/PriorityStrategy.php b/Authorization/Strategy/PriorityStrategy.php
index 9599950c..d7f566ad 100644
--- a/Authorization/Strategy/PriorityStrategy.php
+++ b/Authorization/Strategy/PriorityStrategy.php
@@ -25,11 +25,9 @@
*/
final class PriorityStrategy implements AccessDecisionStrategyInterface, \Stringable
{
- private bool $allowIfAllAbstainDecisions;
-
- public function __construct(bool $allowIfAllAbstainDecisions = false)
- {
- $this->allowIfAllAbstainDecisions = $allowIfAllAbstainDecisions;
+ public function __construct(
+ private bool $allowIfAllAbstainDecisions = false,
+ ) {
}
public function decide(\Traversable $results): bool
diff --git a/Authorization/Strategy/UnanimousStrategy.php b/Authorization/Strategy/UnanimousStrategy.php
index 1f3b85c5..d47d8994 100644
--- a/Authorization/Strategy/UnanimousStrategy.php
+++ b/Authorization/Strategy/UnanimousStrategy.php
@@ -24,11 +24,9 @@
*/
final class UnanimousStrategy implements AccessDecisionStrategyInterface, \Stringable
{
- private bool $allowIfAllAbstainDecisions;
-
- public function __construct(bool $allowIfAllAbstainDecisions = false)
- {
- $this->allowIfAllAbstainDecisions = $allowIfAllAbstainDecisions;
+ public function __construct(
+ private bool $allowIfAllAbstainDecisions = false,
+ ) {
}
public function decide(\Traversable $results): bool
diff --git a/Authorization/TraceableAccessDecisionManager.php b/Authorization/TraceableAccessDecisionManager.php
index cb44dce4..0b82eb3a 100644
--- a/Authorization/TraceableAccessDecisionManager.php
+++ b/Authorization/TraceableAccessDecisionManager.php
@@ -25,17 +25,15 @@
*/
class TraceableAccessDecisionManager implements AccessDecisionManagerInterface
{
- private AccessDecisionManagerInterface $manager;
private ?AccessDecisionStrategyInterface $strategy = null;
/** @var iterable */
private iterable $voters = [];
private array $decisionLog = []; // All decision logs
private array $currentLog = []; // Logs being filled in
- public function __construct(AccessDecisionManagerInterface $manager)
- {
- $this->manager = $manager;
-
+ public function __construct(
+ private AccessDecisionManagerInterface $manager,
+ ) {
// The strategy and voters are stored in a private properties of the decorated service
if (property_exists($manager, 'strategy')) {
$reflection = new \ReflectionProperty($manager::class, 'strategy');
@@ -87,7 +85,7 @@ public function getStrategy(): string
if (null === $this->strategy) {
return '-';
}
- if (method_exists($this->strategy, '__toString')) {
+ if ($this->strategy instanceof \Stringable) {
return (string) $this->strategy;
}
diff --git a/Authorization/Voter/AuthenticatedVoter.php b/Authorization/Voter/AuthenticatedVoter.php
index d7b2b224..a0011868 100644
--- a/Authorization/Voter/AuthenticatedVoter.php
+++ b/Authorization/Voter/AuthenticatedVoter.php
@@ -33,11 +33,9 @@ class AuthenticatedVoter implements CacheableVoterInterface
public const IS_REMEMBERED = 'IS_REMEMBERED';
public const PUBLIC_ACCESS = 'PUBLIC_ACCESS';
- private AuthenticationTrustResolverInterface $authenticationTrustResolver;
-
- public function __construct(AuthenticationTrustResolverInterface $authenticationTrustResolver)
- {
- $this->authenticationTrustResolver = $authenticationTrustResolver;
+ public function __construct(
+ private AuthenticationTrustResolverInterface $authenticationTrustResolver,
+ ) {
}
public function vote(TokenInterface $token, mixed $subject, array $attributes): int
diff --git a/Authorization/Voter/ExpressionVoter.php b/Authorization/Voter/ExpressionVoter.php
index 6de9c954..bab32830 100644
--- a/Authorization/Voter/ExpressionVoter.php
+++ b/Authorization/Voter/ExpressionVoter.php
@@ -26,17 +26,12 @@
*/
class ExpressionVoter implements CacheableVoterInterface
{
- private ExpressionLanguage $expressionLanguage;
- private AuthenticationTrustResolverInterface $trustResolver;
- private AuthorizationCheckerInterface $authChecker;
- private ?RoleHierarchyInterface $roleHierarchy;
-
- public function __construct(ExpressionLanguage $expressionLanguage, AuthenticationTrustResolverInterface $trustResolver, AuthorizationCheckerInterface $authChecker, ?RoleHierarchyInterface $roleHierarchy = null)
- {
- $this->expressionLanguage = $expressionLanguage;
- $this->trustResolver = $trustResolver;
- $this->authChecker = $authChecker;
- $this->roleHierarchy = $roleHierarchy;
+ public function __construct(
+ private ExpressionLanguage $expressionLanguage,
+ private AuthenticationTrustResolverInterface $trustResolver,
+ private AuthorizationCheckerInterface $authChecker,
+ private ?RoleHierarchyInterface $roleHierarchy = null,
+ ) {
}
public function supportsAttribute(string $attribute): bool
diff --git a/Authorization/Voter/RoleHierarchyVoter.php b/Authorization/Voter/RoleHierarchyVoter.php
index 3535ca11..110faa03 100644
--- a/Authorization/Voter/RoleHierarchyVoter.php
+++ b/Authorization/Voter/RoleHierarchyVoter.php
@@ -22,12 +22,10 @@
*/
class RoleHierarchyVoter extends RoleVoter
{
- private RoleHierarchyInterface $roleHierarchy;
-
- public function __construct(RoleHierarchyInterface $roleHierarchy, string $prefix = 'ROLE_')
- {
- $this->roleHierarchy = $roleHierarchy;
-
+ public function __construct(
+ private RoleHierarchyInterface $roleHierarchy,
+ string $prefix = 'ROLE_',
+ ) {
parent::__construct($prefix);
}
diff --git a/Authorization/Voter/RoleVoter.php b/Authorization/Voter/RoleVoter.php
index dbf50478..3c65fb63 100644
--- a/Authorization/Voter/RoleVoter.php
+++ b/Authorization/Voter/RoleVoter.php
@@ -20,11 +20,9 @@
*/
class RoleVoter implements CacheableVoterInterface
{
- private string $prefix;
-
- public function __construct(string $prefix = 'ROLE_')
- {
- $this->prefix = $prefix;
+ public function __construct(
+ private string $prefix = 'ROLE_',
+ ) {
}
public function vote(TokenInterface $token, mixed $subject, array $attributes): int
@@ -38,10 +36,8 @@ public function vote(TokenInterface $token, mixed $subject, array $attributes):
}
$result = VoterInterface::ACCESS_DENIED;
- foreach ($roles as $role) {
- if ($attribute === $role) {
- return VoterInterface::ACCESS_GRANTED;
- }
+ if (\in_array($attribute, $roles, true)) {
+ return VoterInterface::ACCESS_GRANTED;
}
}
diff --git a/Authorization/Voter/TraceableVoter.php b/Authorization/Voter/TraceableVoter.php
index 412bb976..1abc7c70 100644
--- a/Authorization/Voter/TraceableVoter.php
+++ b/Authorization/Voter/TraceableVoter.php
@@ -24,13 +24,10 @@
*/
class TraceableVoter implements CacheableVoterInterface
{
- private VoterInterface $voter;
- private EventDispatcherInterface $eventDispatcher;
-
- public function __construct(VoterInterface $voter, EventDispatcherInterface $eventDispatcher)
- {
- $this->voter = $voter;
- $this->eventDispatcher = $eventDispatcher;
+ public function __construct(
+ private VoterInterface $voter,
+ private EventDispatcherInterface $eventDispatcher,
+ ) {
}
public function vote(TokenInterface $token, mixed $subject, array $attributes): int
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 47b4a210..7cf09c70 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,13 @@
CHANGELOG
=========
+7.2
+---
+
+ * Make `AccessDecisionStrategyTestCase` compatible with PHPUnit 10+
+ * Add `$token` argument to `UserCheckerInterface::checkPostAuth()`
+ * Deprecate argument `$secret` of `RememberMeToken`
+ * Deprecate returning an empty string in `UserInterface::getUserIdentifier()`
7.0
---
diff --git a/Event/AuthenticationEvent.php b/Event/AuthenticationEvent.php
index 6fca50d4..f1683558 100644
--- a/Event/AuthenticationEvent.php
+++ b/Event/AuthenticationEvent.php
@@ -21,15 +21,13 @@
*/
class AuthenticationEvent extends Event
{
- private TokenInterface $authenticationToken;
-
- public function __construct(TokenInterface $token)
- {
- $this->authenticationToken = $token;
+ public function __construct(
+ private TokenInterface $token,
+ ) {
}
public function getAuthenticationToken(): TokenInterface
{
- return $this->authenticationToken;
+ return $this->token;
}
}
diff --git a/Event/VoteEvent.php b/Event/VoteEvent.php
index 1b1d6a33..edc66b36 100644
--- a/Event/VoteEvent.php
+++ b/Event/VoteEvent.php
@@ -23,17 +23,12 @@
*/
final class VoteEvent extends Event
{
- private VoterInterface $voter;
- private mixed $subject;
- private array $attributes;
- private int $vote;
-
- public function __construct(VoterInterface $voter, mixed $subject, array $attributes, int $vote)
- {
- $this->voter = $voter;
- $this->subject = $subject;
- $this->attributes = $attributes;
- $this->vote = $vote;
+ public function __construct(
+ private VoterInterface $voter,
+ private mixed $subject,
+ private array $attributes,
+ private int $vote,
+ ) {
}
public function getVoter(): VoterInterface
diff --git a/Exception/LazyResponseException.php b/Exception/LazyResponseException.php
index e26a3347..a354e68e 100644
--- a/Exception/LazyResponseException.php
+++ b/Exception/LazyResponseException.php
@@ -20,11 +20,9 @@
*/
class LazyResponseException extends \Exception implements ExceptionInterface
{
- private Response $response;
-
- public function __construct(Response $response)
- {
- $this->response = $response;
+ public function __construct(
+ private Response $response,
+ ) {
}
public function getResponse(): Response
diff --git a/Exception/TooManyLoginAttemptsAuthenticationException.php b/Exception/TooManyLoginAttemptsAuthenticationException.php
index da1a1a7a..7bb74d64 100644
--- a/Exception/TooManyLoginAttemptsAuthenticationException.php
+++ b/Exception/TooManyLoginAttemptsAuthenticationException.php
@@ -19,11 +19,9 @@
*/
class TooManyLoginAttemptsAuthenticationException extends AuthenticationException
{
- private ?int $threshold;
-
- public function __construct(?int $threshold = null)
- {
- $this->threshold = $threshold;
+ public function __construct(
+ private ?int $threshold = null,
+ ) {
}
public function getMessageData(): array
diff --git a/README.md b/README.md
index 5bb87c3c..fc50dcc6 100644
--- a/README.md
+++ b/README.md
@@ -8,8 +8,8 @@ so called user providers that hold the users credentials.
Getting Started
---------------
-```
-$ composer require symfony/security-core
+```bash
+composer require symfony/security-core
```
```php
@@ -41,7 +41,7 @@ if (!$accessDecisionManager->decide($token, ['ROLE_ADMIN'])) {
Sponsor
-------
-The Security component for Symfony 7.0 is [backed][1] by [SymfonyCasts][2].
+The Security component for Symfony 7.1 is [backed][1] by [SymfonyCasts][2].
Learn Symfony faster by watching real projects being built and actively coding
along with them. SymfonyCasts bridges that learning gap, bringing you video
diff --git a/Resources/translations/security.bg.xlf b/Resources/translations/security.bg.xlf
index 7fdd4252..5c49168c 100644
--- a/Resources/translations/security.bg.xlf
+++ b/Resources/translations/security.bg.xlf
@@ -76,7 +76,7 @@
Too many failed login attempts, please try again in %minutes% minutes.
- Твърде много неуспешни опити за вход, моля опитайте отново след %minutes% минути.
+ Твърде много неуспешни опити за вход, моля опитайте отново след %minutes% минути.
An authentication exception occurred.
- שגיאה באימות
+ התרחשה שגיאה באימות.Authentication credentials could not be found.
- פרטי זיהוי לא נמצאו.
+ פרטי הזיהוי לא נמצאו.Authentication request could not be processed due to a system problem.
- לא ניתן היה לעבד את בקשת אימות בגלל בעיית מערכת.
+ לא ניתן היה לעבד את בקשת האימות בגלל בעיית מערכת.Invalid credentials.
@@ -20,7 +20,7 @@
Cookie has already been used by someone else.
- עוגיה כבר שומשה.
+ עוגיה כבר שומשה על ידי מישהו אחר.Not privileged to request the resource.
@@ -32,15 +32,15 @@
No authentication provider found to support the authentication token.
- לא נמצא ספק אימות המתאימה לבקשה.
+ לא נמצא ספק אימות המתאים לבקשה.No session available, it either timed out or cookies are not enabled.
- אין סיישן זמין, או שתם הזמן הקצוב או העוגיות אינן מופעלות.
+ אין מפגש זמין, תם הזמן הקצוב או שהעוגיות אינן מופעלות.No token could be found.
- הטוקן לא נמצא.
+ אסימון לא נמצא.Username could not be found.
@@ -72,11 +72,11 @@
Too many failed login attempts, please try again in %minutes% minute.
- יותר מדי ניסיונות כניסה כושלים, אנא נסה שוב בוד %minutes% דקה.
+ יותר מדי ניסיונות כניסה כושלים, אנא נסה שוב בעוד %minutes% דקה.Too many failed login attempts, please try again in %minutes% minutes.
- יותר מדי ניסיונות כניסה כושלים, אנא נסה שוב בעוד %minutes% דקות.
+ יותר מדי ניסיונות כניסה כושלים, אנא נסה שוב בעוד %minutes% דקות.