8000 [DependencyInjection] add union types · symfony/symfony@e017977 · GitHub
[go: up one dir, main page]

Skip to content

Commit e017977

Browse files
[DependencyInjection] add union types
1 parent 76ee4a5 commit e017977

File tree

74 files changed

+154
-396
lines changed

Some content is hidden

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

74 files changed

+154
-396
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class BoundArgument implements ArgumentInterface
2828
private $type;
2929
private $file;
3030

31-
public function __construct($value, bool $trackUsage = true, int $type = 0, string $file = null)
31+
public function __construct(mixed $value, bool $trackUsage = true, int $type = 0, string $file = null)
3232
{
3333
$this->value = $value;
3434
if ($trackUsage) {

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ class RewindableGenerator implements \IteratorAggregate, \Countable
1919
private $generator;
2020
private $count;
2121

22-
/**
23-
* @param int|callable $count
24-
*/
25-
public function __construct(callable $generator, $count)
22+
public function __construct(callable $generator, int|callable $count)
2623
{
2724
$this->generator = $generator;
2825
$this->count = $count;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(\Closure $factory, array $serviceMap, array $service
3737
*
3838
* @return mixed
3939
*/
40-
public function get($id)
40+
public function get(string $id)
4141
{
4242
return isset($this->serviceMap[$id]) ? ($this->factory)(...$this->serviceMap[$id]) : parent::get($id);
4343
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ServiceLocatorArgument implements ArgumentInterface
2727
/**
2828
* @param Reference[]|TaggedIteratorArgument $values
2929
*/
30-
public function __construct($values = [])
30+
public function __construct(array|TaggedIteratorArgument $values = [])
3131
{
3232
if ($values instanceof TaggedIteratorArgument) {
3333
$this->taggedIteratorArgument = $values;

src/Symfony/Component/DependencyInjection/ChildDefinition.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ public function getParent()
4444
/**
4545
* Sets the Definition to inherit from.
4646
*
47-
* @param string $parent
48-
*
4947
* @return $this
5048
*/
51-
public function setParent($parent)
49+
public function setParent(string $parent)
5250
{
5351
$this->parent = $parent;
5452

@@ -61,13 +59,11 @@ public function setParent($parent)
6159
* If replaceArgument() has been used to replace an argument, this method
6260
* will return the replacement value.
6361
*
64-
* @param int|string $index
65-
*
6662
* @return mixed The argument value
6763
*
6864
* @throws OutOfBoundsException When the argument does not exist
6965
*/
70-
public function getArgument($index)
66+
public function getArgument(int|string $index)
7167
{
7268
if (\array_key_exists('index_'.$index, $this->arguments)) {
7369
return $this->arguments['index_'.$index];
@@ -84,14 +80,11 @@ public function getArgument($index)
8480
* certain conventions when you want to overwrite the arguments of the
8581
* parent definition, otherwise your arguments will only be appended.
8682
*
87-
* @param int|string $index
88-
* @param mixed $value
89-
*
9083
* @return $this
9184
*
9285
* @throws InvalidArgumentException when $index isn't an integer
9386
*/
94-
public function replaceArgument($index, $value)
87+
public function replaceArgument(int|string $index, mixed $value)
9588
{
9689
if (\is_int($index)) {
9790
$this->arguments['index_'.$index] = $value;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,9 @@ protected function inExpression(bool $reset = true): bool
6767
/**
6868
* Processes a value found in a definition tree.
6969
*
70-
* @param mixed $value
71-
*
7270
* @return mixed The processed value
7371
*/
74-
protected function processValue($value, bool $isRoot = false)
72+
protected function processValue(mixed $value, bool $isRoot = false)
7573
{
7674
if (\is_array($value)) {
7775
foreach ($value as $k => $v) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(string $tagName = 'container.private')
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
protected function processValue($value, bool $isRoot = false)
36+
protected function processValue(mixed $value, bool $isRoot = false)
3737
{
3838
if ($value instanceof Reference && isset($this->aliases[$id = (string) $value])) {
3939
return new Reference($this->aliases[$id], $value->getInvalidBehavior());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function process(ContainerBuilder $container)
7676
}
7777
}
7878

79-
protected function processValue($value, bool $isRoot = false)
79+
protected function processValue(mixed $value, bool $isRoot = false)
8080
{
8181
$lazy = $this->lazy;
8282
$inExpression = $this->inExpression();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function process(ContainerBuilder $container): void
2929
parent::process($container);
3030
}
3131

32-
protected function processValue($value, bool $isRoot = false)
32+
protected function processValue(mixed $value, bool $isRoot = false)
3333
{
3434
if (!$value instanceof Definition
3535
|| !$value->isAutoconfigured()

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function process(ContainerBuilder $container)
7272
/**
7373
* {@inheritdoc}
7474
*/
75-
protected function processValue($value, bool $isRoot = false)
75+
protected function processValue(mixed $value, bool $isRoot = false)
7676
{
7777
try {
7878
return $this->doProcessValue($value, $isRoot);
@@ -87,10 +87,7 @@ protected function processValue($value, bool $isRoot = false)
8787
}
8888
}
8989

90-
/**
91-
* @return mixed
92-
*/
93-
private function doProcessValue($value, bool $isRoot = false)
90+
private function doProcessValue(mixed $value, bool $isRoot = false): mixed
9491
{
9592
if ($value instanceof TypedReference) {
9693
if ($ref = $this->getAutowiredReference($value)) {
@@ -408,7 +405,7 @@ private function set(string $type, string $id)
408405
$this->ambiguousServiceTypes[$type][] = $id;
409406
}
410407

411-
private function createTypeNotFoundMessageCallback(TypedReference $reference, string $label): callable
408+
private function createTypeNotFoundMessageCallback(TypedReference $reference, string $label): \Closure
412409
{
413410
if (null === $this->typesClone->container) {
414411
$this->typesClone->container = new ContainerBuilder($this->container->getParameterBag());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AutowireRequiredMethodsPass extends AbstractRecursivePass
2424
/**
2525
* {@inheritdoc}
2626
*/
27-
protected function processValue($value, bool $isRoot = false)
27+
protected function processValue(mixed $value, bool $isRoot = false)
2828
{
2929
$value = parent::processValue($value, $isRoot);
3030

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class AutowireRequiredPropertiesPass extends AbstractRecursivePass
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
protected function processValue($value, bool $isRoot = false)
30+
protected function processValue(mixed $value, bool $isRoot = false)
3131
{
3232
$value = parent::processValue($value, $isRoot);
3333

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(bool $throwExceptions = true)
3232
/**
3333
* {@inheritdoc}
3434
*/
35-
protected function processValue($value, bool $isRoot = false)
35+
protected function processValue(mixed $value, bool $isRoot = false)
3636
{
3737
if (!$value instanceof Definition) {
3838
return parent::processValue($value, $isRoot);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function process(ContainerBuilder $container)
4343
}
4444
}
4545

46-
protected function processValue($value, bool $isRoot = false)
46+
protected function processValue(mixed $value, bool $isRoot = false)
4747
{
4848
if (!$value instanceof Reference) {
4949
return parent::processValue($value, $isRoot);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
class CheckReferenceValidityPass extends AbstractRecursivePass
2727
{
28-
protected function processValue($value, bool $isRoot = false)
28+
protected function processValue(mixed $value, bool $isRoot = false)
2929
{
3030
if ($isRoot && $value instanceof Definition && ($value->isSynthetic() || $value->isAbstract())) {
3131
return $value;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __construct(bool $autoload = false, array $skippedIds = [])
7878
/**
7979
* {@inheritdoc}
8080
*/
81-
protected function processValue($value, bool $isRoot = false)
81+
protected function processValue(mixed $value, bool $isRoot = false)
8282
{
8383
if (isset($this->skippedIds[$this->currentId])) {
8484
return $value;
@@ -158,7 +158,7 @@ private function checkTypeDeclarations(Definition $checkedDefinition, \Reflectio
158158
/**
159159
* @throws InvalidParameterTypeException When a parameter is not compatible with the declared type
160160
*/
161-
private function checkType(Definition $checkedDefinition, $value, \ReflectionParameter $parameter, ?string $envPlaceholderUniquePrefix, \ReflectionType $reflectionType = null): void
161+
private function checkType(Definition $checkedDefinition, mixed $value, \ReflectionParameter $parameter, ?string $envPlaceholderUniquePrefix, \ReflectionType $reflectionType = null): void
162162
{
163163
$reflectionType = $reflectionType ?? $parameter->getType();
164164

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function process(ContainerBuilder $container)
121121
}
122122
}
123123

124-
protected function processValue($value, bool $isRoot = false)
124+
protected function processValue(mixed $value, bool $isRoot = false)
125125
{
126126
if ($value instanceof Reference && $this->innerId === (string) $value) {
127127
return new Reference($this->currentId, $value->getInvalidBehavior());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DefinitionErrorExceptionPass extends AbstractRecursivePass
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
protected function processValue($value, bool $isRoot = false)
29+
protected function processValue(mixed $value, bool $isRoot = false)
3030
{
3131
if (!$value instanceof Definition || !$value->hasErrors()) {
3232
return parent::processValue($value, $isRoot);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function process(ContainerBuilder $container)
107107
/**
108108
* {@inheritdoc}
109109
*/
110-
protected function processValue($value, bool $isRoot = false)
110+
protected function processValue(mixed $value, bool $isRoot = false)
111111
{
112112
if ($value instanceof ArgumentInterface) {
113113
// Reference found in ArgumentInterface::getValues() are not inlineable

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function compile(bool $resolveEnvPlaceholders = false)
195195
/**
196196
* {@inheritdoc}
197197
*/
198-
public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs = null)
198+
public function resolveEnvPlaceholders(mixed $value, string|bool|null $format = null, array &$usedEnvs = null)
199199
{
200200
if (true !== $format || !\is_string($value)) {
201201
return parent::resolveEnvPlaceholders($value, $format, $usedEnvs);

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ trait PriorityTaggedServiceTrait
3535
* @see https://bugs.php.net/53710
3636
* @see https://bugs.php.net/60926
3737
*
38-
* @param string|TaggedIteratorArgument $tagName
39-
*
4038
* @return Reference[]
4139
*/
42-
private function findAndSortTaggedServices($tagName, ContainerBuilder $container): array
40+
private function findAndSortTaggedServices(string|TaggedIteratorArgument $tagName, ContainerBuilder $container): array
4341
{
4442
$indexAttribute = $defaultIndexMethod = $needsIndexes = $defaultPriorityMethod = null;
4543

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131
class RegisterServiceSubscribersPass extends AbstractRecursivePass
3232
{
33-
protected function processValue($value, bool $isRoot = false)
33+
protected function processValue(mixed $value, bool $isRoot = false)
3434
{
3535
if (!$value instanceof Definition || $value->isAbstract() || $value->isSynthetic() || !$value->hasTag('container.service_subscriber')) {
3636
return parent::processValue($value, $isRoot);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function process(ContainerBuilder $container)
7575
/**
7676
* {@inheritdoc}
7777
*/
78-
protected function processValue($value, bool $isRoot = false)
78+
protected function processValue(mixed $value, bool $isRoot = false)
7979
{
8080
if (!$value instanceof Reference) {
8181
return parent::processValue($value, $isRoot);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function process(ContainerBuilder $container)
7979
/**
8080
* {@inheritdoc}
8181
*/
82-
protected function processValue($value, bool $isRoot = false)
82+
protected function processValue(mixed $value, bool $isRoot = false)
8383
{
8484
if ($value instanceof Reference && isset($this->replacements[$referenceId = (string) $value])) {
8585
// Perform the replacement

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function process(ContainerBuilder $container)
9393
/**
9494
* {@inheritdoc}
9595
*/
96-
protected function processValue($value, bool $isRoot = false)
96+
protected function processValue(mixed $value, bool $isRoot = false)
9797
{
9898
if ($value instanceof TypedReference && $value->getType() === (string) $value) {
9999
// Already checked

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ResolveChildDefinitionsPass extends AbstractRecursivePass
2929
{
3030
private $currentPath;
3131

32-
protected function processValue($value, bool $isRoot = false)
32+
protected function processValue(mixed $value, bool $isRoot = false)
3333
{
3434
if (!$value instanceof Definition) {
3535
return parent::processValue($value, $isRoot);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class ResolveEnvPlaceholdersPass extends AbstractRecursivePass
2020
{
21-
protected function processValue($value, bool $isRoot = false)
21+
protected function processValue(mixed $value, bool $isRoot = false)
2222
{
2323
if (\is_string($value)) {
2424
return $this->container->resolveEnvPlaceholders($value, true);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ResolveFactoryClassPass extends AbstractRecursivePass
2222
/**
2323
* {@inheritdoc}
2424
*/
25-
protected function processValue($value, bool $isRoot = false)
25+
protected function processValue(mixed $value, bool $isRoot = false)
2626
{
2727
if ($value instanceof Definition && \is_array($factory = $value->getFactory()) && null === $factory[0]) {
2828
if (null === $class = $value->getClass()) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function process(ContainerBuilder $container)
5151
/**
5252
* {@inheritdoc}
5353
*/
54-
protected function processValue($value, bool $isRoot = false)
54+
protected function processValue(mixed $value, bool $isRoot = false)
5555
{
5656
if ($value instanceof ArgumentInterface) {
5757
return $value;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ public function process(ContainerBuilder $container)
5353
/**
5454
* Processes arguments to determine invalid references.
5555
*
56-
* @return mixed
57-
*
5856
* @throws RuntimeException When an invalid reference is found
5957
*/
60-
private function processValue($value, int $rootLevel = 0, int $level = 0)
58+
private function processValue(mixed $value, int $rootLevel = 0, int $level = 0): mixed
6159
{
6260
if ($value instanceof ServiceClosureArgument) {
6361
$value->setValues($this->processValue($value->getValues(), 1, 1));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ResolveNamedArgumentsPass extends AbstractRecursivePass
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
protected function processValue($value, bool $isRoot = false)
30+
protected function processValue(mixed $value, bool $isRoot = false)
3131
{
3232
if ($value instanceof AbstractArgument && $value->getText().'.' === $value->getTextWithContext()) {
3333
$value->setContext(sprintf('A value found in service "%s"', $this->currentId));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function process(ContainerBuilder $container)
7474
/**
7575
* {@inheritdoc}
7676
*/
77-
protected function processValue($value, bool $isRoot = false)
77+
protected function processValue(mixed $value, bool $isRoot = false)
7878
{
7979
if ($value instanceof Reference && ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->hasDefinition($id = (string) $value)) {
8080
$definition = $this->container->getDefinition($id);

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@
2323
class ResolveParameterPlaceHoldersPass extends AbstractRecursivePass
2424
{
2525
private $bag;
26-
private $resolveArrays;
27-
private $throwOnResolveException;
2826

29-
public function __construct($resolveArrays = true, $throwOnResolveException = true)
27+
public function __construct(
28+
private bool $resolveArrays = true,
29+
private bool $throwOnResolveException = true,
30+
)
3031
{
31-
$this->resolveArrays = $resolveArrays;
32-
$this->throwOnResolveException = $throwOnResolveException;
3332
}
3433

3534
/**
@@ -60,7 +59,7 @@ public function process(ContainerBuilder $container)
6059
$this->bag = null;
6160
}
6261

63-
protected function processValue($value, bool $isRoot = false)
62+
protected function processValue(mixed $value, bool $isRoot = false)
6463
{
6564
if (\is_string($value)) {
6665
try {

0 commit comments

Comments
 (0)
0