Skip to content

Commit 97e729b

Browse files
committed
use constructor property promotion
1 parent 4276b5b commit 97e729b

10 files changed

+50
-82
lines changed

Diff for: CacheWarmer/ExpressionCacheWarmer.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@
2020
*/
2121
class ExpressionCacheWarmer implements CacheWarmerInterface
2222
{
23-
private iterable $expressions;
24-
private ExpressionLanguage $expressionLanguage;
25-
2623
/**
2724
* @param iterable<mixed, Expression|string> $expressions
2825
*/
29-
public function __construct(iterable $expressions, ExpressionLanguage $expressionLanguage)
30-
{
31-
$this->expressions = $expressions;
32-
$this->expressionLanguage = $expressionLanguage;
26+
public function __construct(
27+
private iterable $expressions,
28+
private ExpressionLanguage $expressionLanguage,
29+
) {
3330
}
3431

3532
public function isOptional(): bool

Diff for: Command/DebugFirewallCommand.php

+6-12
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,16 @@
3232
#[AsCommand(name: 'debug:firewall', description: 'Display information about your security firewall(s)')]
3333
final class DebugFirewallCommand extends Command
3434
{
35-
private array $firewallNames;
36-
private ContainerInterface $contexts;
37-
private ContainerInterface $eventDispatchers;
38-
private array $authenticators;
39-
4035
/**
4136
* @param string[] $firewallNames
4237
* @param AuthenticatorInterface[][] $authenticators
4338
*/
44-
public function __construct(array $firewallNames, ContainerInterface $contexts, ContainerInterface $eventDispatchers, array $authenticators)
45-
{
46-
$this->firewallNames = $firewallNames;
47-
$this->contexts = $contexts;
48-
$this->eventDispatchers = $eventDispatchers;
49-
$this->authenticators = $authenticators;
50-
39+
public function __construct(
40+
private array $firewallNames,
41+
private ContainerInterface $contexts,
42+
private ContainerInterface $eventDispatchers,
43+
private array $authenticators,
44+
) {
5145
parent::__construct();
5246
}
5347

Diff for: DataCollector/SecurityDataCollector.php

+8-14
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,16 @@
3636
*/
3737
class SecurityDataCollector extends DataCollector implements LateDataCollectorInterface
3838
{
39-
private ?TokenStorageInterface $tokenStorage;
40-
private ?RoleHierarchyInterface $roleHierarchy;
41-
private ?LogoutUrlGenerator $logoutUrlGenerator;
42-
private ?AccessDecisionManagerInterface $accessDecisionManager;
43-
private ?FirewallMapInterface $firewallMap;
44-
private ?TraceableFirewallListener $firewall;
4539
private bool $hasVarDumper;
4640

47-
public function __construct(?TokenStorageInterface $tokenStorage = null, ?RoleHierarchyInterface $roleHierarchy = null, ?LogoutUrlGenerator $logoutUrlGenerator = null, ?AccessDecisionManagerInterface $accessDecisionManager = null, ?FirewallMapInterface $firewallMap = null, ?TraceableFirewallListener $firewall = null)
48-
{
49-
$this->tokenStorage = $tokenStorage;
50-
$this->roleHierarchy = $roleHierarchy;
51-
$this->logoutUrlGenerator = $logoutUrlGenerator;
52-
$this->accessDecisionManager = $accessDecisionManager;
53-
$this->firewallMap = $firewallMap;
54-
$this->firewall = $firewall;
41+
public function __construct(
42+
private ?TokenStorageInterface $tokenStorage = null,
43+
private ?RoleHierarchyInterface $roleHierarchy = null,
44+
private ?LogoutUrlGenerator $logoutUrlGenerator = null,
45+
private ?AccessDecisionManagerInterface $accessDecisionManager = null,
46+
private ?FirewallMapInterface $firewallMap = null,
47+
private ?TraceableFirewallListener $firewall = null,
48+
) {
5549
$this->hasVarDumper = class_exists(ClassStub::class);
5650
}
5751

Diff for: DependencyInjection/MainConfiguration.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,13 @@ class MainConfiguration implements ConfigurationInterface
3636
/** @internal */
3737
public const STRATEGY_PRIORITY = 'priority';
3838

39-
private array $factories;
40-
private array $userProviderFactories;
41-
4239
/**
4340
* @param array<AuthenticatorFactoryInterface> $factories
4441
*/
45-
public function __construct(array $factories, array $userProviderFactories)
46-
{
47-
$this->factories = $factories;
48-
$this->userProviderFactories = $userProviderFactories;
42+
public function __construct(
43+
private array $factories,
44+
private array $userProviderFactories,
45+
) {
4946
}
5047

5148
/**

Diff for: EventListener/FirewallListener.php

+5-8
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,11 @@
2525
*/
2626
class FirewallListener extends Firewall
2727
{
28-
private FirewallMapInterface $map;
29-
private LogoutUrlGenerator $logoutUrlGenerator;
30-
31-
public function __construct(FirewallMapInterface $map, EventDispatcherInterface $dispatcher, LogoutUrlGenerator $logoutUrlGenerator)
32-
{
33-
$this->map = $map;
34-
$this->logoutUrlGenerator = $logoutUrlGenerator;
35-
28+
public function __construct(
29+
private FirewallMapInterface $map,
30+
EventDispatcherInterface $dispatcher,
31+
private LogoutUrlGenerator $logoutUrlGenerator,
32+
) {
3633
parent::__construct($map, $dispatcher);
3734
}
3835

Diff for: EventListener/VoteListener.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
*/
2525
class VoteListener implements EventSubscriberInterface
2626
{
27-
private TraceableAccessDecisionManager $traceableAccessDecisionManager;
28-
29-
public function __construct(TraceableAccessDecisionManager $traceableAccessDecisionManager)
30-
{
31-
$this->traceableAccessDecisionManager = $traceableAccessDecisionManager;
27+
public function __construct(
28+
private TraceableAccessDecisionManager $traceableAccessDecisionManager,
29+
) {
3230
}
3331

3432
public function onVoterVote(VoteEvent $event): void

Diff for: RememberMe/DecoratedRememberMeHandler.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
*/
2525
final class DecoratedRememberMeHandler implements RememberMeHandlerInterface
2626
{
27-
private RememberMeHandlerInterface $handler;
28-
29-
public function __construct(RememberMeHandlerInterface $handler)
30-
{
31-
$this->handler = $handler;
27+
public function __construct(
28+
private RememberMeHandlerInterface $handler,
29+
) {
3230
}
3331

3432
public function createRememberMeCookie(UserInterface $user): void

Diff for: Security/FirewallContext.php

+6-11
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,15 @@
2222
*/
2323
class FirewallContext
2424
{
25-
private iterable $listeners;
26-
private ?ExceptionListener $exceptionListener;
27-
private ?LogoutListener $logoutListener;
28-
private ?FirewallConfig $config;
29-
3025
/**
3126
* @param iterable<mixed, callable> $listeners
3227
*/
33-
public function __construct(iterable $listeners, ?ExceptionListener $exceptionListener = null, ?LogoutListener $logoutListener = null, ?FirewallConfig $config = null)
34-
{
35-
$this->listeners = $listeners;
36-
$this->exceptionListener = $exceptionListener;
37-
$this->logoutListener = $logoutListener;
38-
$this->config = $config;
28+
public function __construct(
29+
private iterable $listeners,
30+
private ?ExceptionListener $exceptionListener = null,
31+
private ?LogoutListener $logoutListener = null,
32+
private ?FirewallConfig $config = null,
33+
) {
3934
}
4035

4136
public function getConfig(): ?FirewallConfig

Diff for: Security/FirewallMap.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@
2424
*/
2525
class FirewallMap implements FirewallMapInterface
2626
{
27-
private ContainerInterface $container;
28-
private iterable $map;
29-
30-
public function __construct(ContainerInterface $container, iterable $map)
31-
{
32-
$this->container = $container;
33-
$this->map = $map;
27+
public function __construct(
28+
private ContainerInterface $container,
29+
private iterable $map,
30+
) {
3431
}
3532

3633
public function getListeners(Request $request): array

Diff for: Security/LazyFirewallContext.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
*/
2626
class LazyFirewallContext extends FirewallContext
2727
{
28-
private TokenStorage $tokenStorage;
29-
30-
public function __construct(iterable $listeners, ?ExceptionListener $exceptionListener, ?LogoutListener $logoutListener, ?FirewallConfig $config, TokenStorage $tokenStorage)
31-
{
28+
public function __construct(
29+
iterable $listeners,
30+
?ExceptionListener $exceptionListener,
31+
?LogoutListener $logoutListener,
32+
?FirewallConfig $config,
33+
private TokenStorage $tokenStorage,
34+
) {
3235
parent::__construct($listeners, $exceptionListener, $logoutListener, $config);
33-
34-
$this->tokenStorage = $tokenStorage;
3536
}
3637

3738
public function getListeners(): iterable

0 commit comments

Comments
 (0)