Skip to content

Commit c10131d

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

File tree

74 files changed

+153
-395
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

+153
-395
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: 2 additions & 5 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)) {

0 commit comments

Comments
 (0)