Skip to content

Commit 678abb4

Browse files
committed
minor symfony#57329 [DependencyInjection][DomCrawler][ExpressionLanguage][Serializer][VarDumper][Workflow] use constructor property promotion (xabbuh)
This PR was merged into the 7.2 branch. Discussion ---------- [DependencyInjection][DomCrawler][ExpressionLanguage][Serializer][VarDumper][Workflow] use constructor property promotion | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT Commits ------- f184ada use constructor property promotion
2 parents 63ef48f + f184ada commit 678abb4

File tree

83 files changed

+398
-544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+398
-544
lines changed

src/Symfony/Component/DependencyInjection/Alias.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ class Alias
1717
{
1818
private const DEFAULT_DEPRECATION_TEMPLATE = 'The "%alias_id%" service alias is deprecated. You should stop using it, as it will be removed in the future.';
1919

20-
private string $id;
21-
private bool $public;
2220
private array $deprecation = [];
2321

24-
public function __construct(string $id, bool $public = false)
25-
{
26-
$this->id = $id;
27-
$this->public = $public;
22+
public function __construct(
23+
private string $id,
24+
private bool $public = false,
25+
) {
2826
}
2927

3028
/**

src/Symfony/Component/DependencyInjection/Argument/BoundArgument.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,20 @@ final class BoundArgument implements ArgumentInterface
2222

2323
private static int $sequence = 0;
2424

25-
private mixed $value;
2625
private ?int $identifier = null;
2726
private ?bool $used = null;
28-
private int $type;
29-
private ?string $file;
3027

31-
public function __construct(mixed $value, bool $trackUsage = true, int $type = 0, ?string $file = null)
32-
{
33-
$this->value = $value;
28+
public function __construct(
29+
private mixed $value,
30+
bool $trackUsage = true,
31+
private int $type = 0,
32+
private ?string $file = null,
33+
) {
3434
if ($trackUsage) {
3535
$this->identifier = ++self::$sequence;
3636
} else {
3737
$this->used = true;
3838
}
39-
$this->type = $type;
40-
$this->file = $file;
4139
}
4240

4341
public function getValues(): array

src/Symfony/Component/DependencyInjection/Argument/ServiceLocator.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@
2020
*/
2121
class ServiceLocator extends BaseServiceLocator
2222
{
23-
private \Closure $factory;
24-
private array $serviceMap;
25-
private ?array $serviceTypes;
26-
27-
public function __construct(\Closure $factory, array $serviceMap, ?array $serviceTypes = null)
28-
{
29-
$this->factory = $factory;
30-
$this->serviceMap = $serviceMap;
31-
$this->serviceTypes = $serviceTypes;
23+
public function __construct(
24+
private \Closure $factory,
25+
private array $serviceMap,
26+
private ?array $serviceTypes = null,
27+
) {
3228
parent::__construct($serviceMap);
3329
}
3430

src/Symfony/Component/DependencyInjection/Argument/TaggedIteratorArgument.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@
1818
*/
1919
class TaggedIteratorArgument extends IteratorArgument
2020
{
21-
private string $tag;
2221
private mixed $indexAttribute;
2322
private ?string $defaultIndexMethod;
2423
private ?string $defaultPriorityMethod;
25-
private bool $needsIndexes;
26-
private array $exclude;
27-
private bool $excludeSelf = true;
2824

2925
/**
3026
* @param string $tag The name of the tag identifying the target services
@@ -35,21 +31,24 @@ class TaggedIteratorArgument extends IteratorArgument
3531
* @param array $exclude Services to exclude from the iterator
3632
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the iterator
3733
*/
38-
public function __construct(string $tag, ?string $indexAttribute = null, ?string $defaultIndexMethod = null, bool $needsIndexes = false, ?string $defaultPriorityMethod = null, array $exclude = [], bool $excludeSelf = true)
39-
{
34+
public function __construct(
35+
private string $tag,
36+
?string $indexAttribute = null,
37+
?string $defaultIndexMethod = null,
38+
private bool $needsIndexes = false,
39+
?string $defaultPriorityMethod = null,
40+
private array $exclude = [],
41+
private bool $excludeSelf = true,
42+
) {
4043
parent::__construct([]);
4144

4245
if (null === $indexAttribute && $needsIndexes) {
4346
$indexAttribute = preg_match('/[^.]++$/', $tag, $m) ? $m[0] : $tag;
4447
}
4548

46-
$this->tag = $tag;
4749
$this->indexAttribute = $indexAttribute;
4850
$this->defaultIndexMethod = $defaultIndexMethod ?: ($indexAttribute ? 'getDefault'.str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $indexAttribute))).'Name' : null);
49-
$this->needsIndexes = $needsIndexes;
5051
$this->defaultPriorityMethod = $defaultPriorityMethod ?: ($indexAttribute ? 'getDefault'.str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $indexAttribute))).'Priority' : null);
51-
$this->exclude = $exclude;
52-
$this->excludeSelf = $excludeSelf;
5352
}
5453

5554
public function getTag(): string

src/Symfony/Component/DependencyInjection/ChildDefinition.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
*/
2222
class ChildDefinition extends Definition
2323
{
24-
private string $parent;
25-
2624
/**
2725
* @param string $parent The id of Definition instance to decorate
2826
*/
29-
public function __construct(string $parent)
30-
{
31-
$this->parent = $parent;
27+
public function __construct(
28+
private string $parent,
29+
) {
3230
}
3331

3432
/**

src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass
3636

3737
private ServiceReferenceGraph $graph;
3838
private ?Definition $currentDefinition = null;
39-
private bool $onlyConstructorArguments;
40-
private bool $hasProxyDumper;
4139
private bool $lazy;
4240
private bool $byConstructor;
4341
private bool $byFactory;
@@ -47,10 +45,10 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass
4745
/**
4846
* @param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls
4947
*/
50-
public function __construct(bool $onlyConstructorArguments = false, bool $hasProxyDumper = true)
51-
{
52-
$this->onlyConstructorArguments = $onlyConstructorArguments;
53-
$this->hasProxyDumper = $hasProxyDumper;
48+
public function __construct(
49+
private bool $onlyConstructorArguments = false,
50+
private bool $hasProxyDumper = true,
51+
) {
5452
$this->enableExpressionProcessing();
5553
}
5654

src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,15 @@ class AutowirePass extends AbstractRecursivePass
4141
private array $ambiguousServiceTypes;
4242
private array $autowiringAliases;
4343
private ?string $lastFailure = null;
44-
private bool $throwOnAutowiringException;
4544
private ?string $decoratedClass = null;
4645
private ?string $decoratedId = null;
4746
private object $defaultArgument;
4847
private ?\Closure $restorePreviousValue = null;
4948
private ?self $typesClone = null;
5049

51-
public function __construct(bool $throwOnAutowireException = true)
52-
{
53-
$this->throwOnAutowiringException = $throwOnAutowireException;
50+
public function __construct(
51+
private bool $throwOnAutowiringException = true,
52+
) {
5453
$this->defaultArgument = new class() {
5554
public $value;
5655
public $names;

src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ class CheckArgumentsValidityPass extends AbstractRecursivePass
2424
{
2525
protected bool $skipScalars = true;
2626

27-
private bool $throwExceptions;
28-
29-
public function __construct(bool $throwExceptions = true)
30-
{
31-
$this->throwExceptions = $throwExceptions;
27+
public function __construct(
28+
private bool $throwExceptions = true,
29+
) {
3230
}
3331

3432
protected function processValue(mixed $value, bool $isRoot = false): mixed

src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,17 @@ final class CheckTypeDeclarationsPass extends AbstractRecursivePass
6161
'string' => true,
6262
];
6363

64-
private bool $autoload;
65-
private array $skippedIds;
66-
6764
private ExpressionLanguage $expressionLanguage;
6865

6966
/**
7067
* @param bool $autoload Whether services who's class in not loaded should be checked or not.
7168
* Defaults to false to save loading code during compilation.
7269
* @param array $skippedIds An array indexed by the service ids to skip
7370
*/
74-
public function __construct(bool $autoload = false, array $skippedIds = [])
75-
{
76-
$this->autoload = $autoload;
77-
$this->skippedIds = $skippedIds;
71+
public function __construct(
72+
private bool $autoload = false,
73+
private array $skippedIds = [],
74+
) {
7875
}
7976

8077
protected function processValue(mixed $value, bool $isRoot = false): mixed

src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,16 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass
2626
{
2727
protected bool $skipScalars = true;
2828

29-
private ?AnalyzeServiceReferencesPass $analyzingPass;
3029
private array $cloningIds = [];
3130
private array $connectedIds = [];
3231
private array $notInlinedIds = [];
3332
private array $inlinedIds = [];
3433
private array $notInlinableIds = [];
3534
private ?ServiceReferenceGraph $graph = null;
3635

37-
public function __construct(?AnalyzeServiceReferencesPass $analyzingPass = null)
38-
{
39-
$this->analyzingPass = $analyzingPass;
36+
public function __construct(
37+
private ?AnalyzeServiceReferencesPass $analyzingPass = null,
38+
) {
4039
}
4140

4241
public function process(ContainerBuilder $container): void

0 commit comments

Comments
 (0)