Skip to content

Commit f04fd29

Browse files
Merge branch '5.4' into 6.0
* 5.4: [DependencyInjection] Improve array phpdoc of `ContainerBuilder` Match 5.1 mailer configuration [Cache] Make sure PdoAdapter::prune() always returns a bool [HttpKernel] Fix broken mock [HttpClient] Fix handling timeouts when responses are destructed [PropertyInfo] Support for intersection types
2 parents 564af72 + 013d0fb commit f04fd29

File tree

2 files changed

+51
-24
lines changed

2 files changed

+51
-24
lines changed

ContainerBuilder.php

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,35 @@
5454
class ContainerBuilder extends Container implements TaggedContainerInterface
5555
{
5656
/**
57-
* @var ExtensionInterface[]
57+
* @var array<string, ExtensionInterface>
5858
*/
5959
private array $extensions = [];
6060

6161
/**
62-
* @var ExtensionInterface[]
62+
* @var array<string, ExtensionInterface>
6363
*/
6464
private array $extensionsByNs = [];
6565

6666
/**
67-
* @var Definition[]
67+
* @var array<string, Definition>
6868
*/
6969
private array $definitions = [];
7070

7171
/**
72-
* @var Alias[]
72+
* @var array<string, Alias>
7373
*/
7474
private array $aliasDefinitions = [];
7575

7676
/**
77-
* @var ResourceInterface[]
77+
* @var array<string, ResourceInterface>
7878
*/
7979
private array $resources = [];
8080

81+
/**
82+
* @var array<string, array<array<string, mixed>>>
83+
*/
8184
private array $extensionConfigs = [];
85+
8286
private Compiler $compiler;
8387
private bool $trackResources;
8488
private ?InstantiatorInterface $proxyInstantiator = null;
@@ -109,15 +113,24 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
109113
*/
110114
private array $vendors;
111115

116+
/**
117+
* @var array<string, ChildDefinition>
118+
*/
112119
private array $autoconfiguredInstanceof = [];
113120

114121
/**
115-
* @var callable[]
122+
* @var array<string, callable>
116123
*/
117124
private array $autoconfiguredAttributes = [];
118125

126+
/**
127+
* @var array<string, bool>
128+
*/
119129
private array $removedIds = [];
120130

131+
/**
132+
* @var array<int, bool>
133+
*/
121134
private array $removedBindingIds = [];
122135

123136
private const INTERNAL_TYPES = [
@@ -143,7 +156,7 @@ public function __construct(ParameterBagInterface $parameterBag = null)
143156
}
144157

145158
/**
146-
* @var \ReflectionClass[] a list of class reflectors
159+
* @var array<string, \ReflectionClass>
147160
*/
148161
private array $classReflectors;
149162

@@ -204,7 +217,7 @@ public function getExtension(string $name): ExtensionInterface
204217
/**
205218
* Returns all registered extensions.
206219
*
207-
* @return ExtensionInterface[]
220+
* @return array<string, ExtensionInterface>
208221
*/
209222
public function getExtensions(): array
210223
{
@@ -250,7 +263,7 @@ public function addResource(ResourceInterface $resource): static
250263
/**
251264
* Sets the resources for this configuration.
252265
*
253-
* @param ResourceInterface[] $resources An array of resources
266+
* @param array<string, ResourceInterface> $resources
254267
*
255268
* @return $this
256269
*/
@@ -395,8 +408,8 @@ public function fileExists(string $path, bool|string $trackContents = true): boo
395408
/**
396409
* Loads the configuration for an extension.
397410
*
398-
* @param string $extension The extension alias or namespace
399-
* @param array $values An array of values that customizes the extension
411+
* @param string $extension The extension alias or namespace
412+
* @param array<string, mixed>|null $values An array of values that customizes the extension
400413
*
401414
* @return $this
402415
*
@@ -409,13 +422,9 @@ public function loadFromExtension(string $extension, array $values = null): stat
409422
throw new BadMethodCallException('Cannot load from an extension on a compiled container.');
410423
}
411424

412-
if (\func_num_args() < 2) {
413-
$values = [];
414-
}
415-
416425
$namespace = $this->getExtension($extension)->getAlias();
417426

418-
$this->extensionConfigs[$namespace][] = $values;
427+
$this->extensionConfigs[$namespace][] = $values ?? [];
419428

420429
return $this;
421430
}
@@ -644,6 +653,8 @@ public function merge(self $container)
644653

645654
/**
646655
* Returns the configuration array for the given extension.
656+
*
657+
* @return array<array<string, mixed>>
647658
*/
648659
public function getExtensionConfig(string $name): array
649660
{
@@ -656,6 +667,8 @@ public function getExtensionConfig(string $name): array
656667

657668
/**
658669
* Prepends a config array to the configs of the given extension.
670+
*
671+
* @param array<string, mixed> $config
659672
*/
660673
public function prependExtensionConfig(string $name, array $config)
661674
{
@@ -737,6 +750,8 @@ public function getServiceIds(): array
737750

738751
/**
739752
* Gets removed service or alias ids.
753+
*
754+
* @return array<string, bool>
740755
*/
741756
public function getRemovedIds(): array
742757
{
@@ -745,6 +760,8 @@ public function getRemovedIds(): array
745760

746761
/**
747762
* Adds the service aliases.
763+
*
764+
* @param array<string, string|Alias> $aliases
748765
*/
749766
public function addAliases(array $aliases)
750767
{
@@ -755,6 +772,8 @@ public function addAliases(array $aliases)
755772

756773
/**
757774
* Sets the service aliases.
775+
*
776+
* @param array<string, string|Alias> $aliases
758777
*/
759778
public function setAliases(array $aliases)
760779
{
@@ -801,7 +820,7 @@ public function hasAlias(string $id): bool
801820
}
802821

803822
/**
804-
* @return Alias[]
823+
* @return array<string, Alias>
805824
*/
806825
public function getAliases(): array
807826
{
@@ -845,7 +864,7 @@ public function autowire(string $id, string $class = null): Definition
845864
/**
846865
* Adds the service definitions.
847866
*
848-
* @param Definition[] $definitions An array of service definitions
867+
* @param array<string, Definition> $definitions
849868
*/
850869
public function addDefinitions(array $definitions)
851870
{
@@ -857,7 +876,7 @@ public function addDefinitions(array $definitions)
857876
/**
858877
* Sets the service definitions.
859878
*
860-
* @param Definition[] $definitions An array of service definitions
879+
* @param array<string, Definition> $definitions
861880
*/
862881
public function setDefinitions(array $definitions)
863882
{
@@ -868,7 +887,7 @@ public function setDefinitions(array $definitions)
868887
/**
869888
* Gets all service definitions.
870889
*
871-
* @return Definition[]
890+
* @return array<string, Definition>
872891
*/
873892
public function getDefinitions(): array
874893
{
@@ -1165,7 +1184,7 @@ private function doResolveServices(mixed $value, array &$inlineServices = [], bo
11651184
* }
11661185
* }
11671186
*
1168-
* @return array An array of tags with the tagged service as key, holding a list of attribute arrays
1187+
* @return array<string, array> An array of tags with the tagged service as key, holding a list of attribute arrays
11691188
*/
11701189
public function findTaggedServiceIds(string $name, bool $throwOnAbstract = false): array
11711190
{
@@ -1185,6 +1204,8 @@ public function findTaggedServiceIds(string $name, bool $throwOnAbstract = false
11851204

11861205
/**
11871206
* Returns all tags the defined services use.
1207+
*
1208+
* @return string[]
11881209
*/
11891210
public function findTags(): array
11901211
{
@@ -1271,15 +1292,15 @@ public function registerAliasForArgument(string $id, string $type, string $name
12711292
/**
12721293
* Returns an array of ChildDefinition[] keyed by interface.
12731294
*
1274-
* @return ChildDefinition[]
1295+
* @return array<string, ChildDefinition>
12751296
*/
12761297
public function getAutoconfiguredInstanceof(): array
12771298
{
12781299
return $this->autoconfiguredInstanceof;
12791300
}
12801301

12811302
/**
1282-
* @return callable[]
1303+
* @return array<string, callable>
12831304
*/
12841305
public function getAutoconfiguredAttributes(): array
12851306
{
@@ -1419,6 +1440,8 @@ final public static function willBeAvailable(string $package, string $class, arr
14191440
/**
14201441
* Gets removed binding ids.
14211442
*
1443+
* @return array<int, bool>
1444+
*
14221445
* @internal
14231446
*/
14241447
public function getRemovedBindingIds(): array
@@ -1442,6 +1465,8 @@ public function removeBindings(string $id)
14421465
}
14431466

14441467
/**
1468+
* @return string[]
1469+
*
14451470
* @internal
14461471
*/
14471472
public static function getServiceConditionals(mixed $value): array
@@ -1460,6 +1485,8 @@ public static function getServiceConditionals(mixed $value): array
14601485
}
14611486

14621487
/**
1488+
* @return string[]
1489+
*
14631490
* @internal
14641491
*/
14651492
public static function getInitializedConditionals(mixed $value): array

Tests/Loader/YamlFileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public function testExtensionWithNullConfig()
347347
$loader->load('null_config.yml');
348348
$container->compile();
349349

350-
$this->assertSame([null], $container->getParameter('project.configs'));
350+
$this->assertSame([[]], $container->getParameter('project.configs'));
351351
}
352352

353353
public function testSupports()

0 commit comments

Comments
 (0)