8000 Merge branch '5.4' into 6.0 · symfony/symfony@8828d94 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8828d94

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 41b726f + 77c76f4 commit 8828d94

File tree

20 files changed

+184
-46
lines changed

20 files changed

+184
-46
lines changed

psalm.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,13 @@
1717
<directory name="vendor" />
1818
</ignoreFiles>
1919
</projectFiles>
20+
21+
<issueHandlers>
22+
<UndefinedClass>
23+
<errorLevel type="suppress">
24+
<!-- Class has been added in PHP 8.1 -->
25+
<referencedClass name="ReflectionIntersectionType"/>
26+
</errorLevel>
27+
</UndefinedClass>
28+
</issueHandlers>
2029
</psalm>

src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,9 @@
7373
->tag('kernel.event_subscriber')
7474
->tag('kernel.reset', ['method' => 'reset'])
7575
->deprecate('symfony/framework-bundle', '5.2', 'The "%service_id%" service is deprecated, use "mailer.message_logger_listener" instead.')
76+
77+
->set('mailer.message_logger_listener', MessageLoggerListener::class)
78+
->tag('kernel.event_subscriber')
79+
->tag('kernel.reset', ['method' => 'reset'])
7680
;
7781
};

src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer_debug.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,5 @@
2424
'template' => '@WebProfiler/Collector/mailer.html.twig',
2525
'id' => 'mailer',
2626
])
27-
28-
->set('mailer.message_logger_listener', MessageLoggerListener::class)
29-
->tag('kernel.event_subscriber')
30-
->tag('kernel.reset', ['method' => 'reset'])
3127
;
3228
};

src/Symfony/Component/Cache/Adapter/PdoAdapter.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Doctrine\DBAL\Exception\TableNotFoundException;
2020
use Doctrine\DBAL\ParameterType;
2121
use Doctrine\DBAL\Schema\Schema;
22+
use Doctrine\DBAL\Statement;
2223
use Symfony\Component\Cache\Exception\InvalidArgumentException;
2324
use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
2425
use Symfony\Component\Cache\Marshaller\MarshallerInterface;
@@ -206,6 +207,13 @@ public function prune(): bool
206207
$delete->bindValue(':namespace', sprintf('%s%%', $this->namespace), $useDbalConstants ? ParameterType::STRING : \PDO::PARAM_STR);
207208
}
208209
try {
210+
// Doctrine DBAL ^2.13 || >= 3.1
211+
if ($delete instanceof Statement && method_exists($delete, 'executeStatement')) {
212+
$delete->executeStatement();
213+
214+
return true;
215+
}
216+
209217
return $delete->execute();
210218
} catch (TableNotFoundException $e) {
211219
return true;

src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function testPrune()
227227
$doSet('qux', 'qux-val', new \DateInterval('PT20S'));
228228

229229
sleep(30);
230-
$cache->prune();
230+
$this->assertTrue($cache->prune());
231231
$this->assertTrue($this->isPruned($cache, 'foo'));
232232
$this->assertTrue($this->isPruned($cache, 'bar'));
233233
$this->assertTrue($this->isPruned($cache, 'baz'));
@@ -238,27 +238,27 @@ public function testPrune()
238238
$doSet('baz', 'baz-val', new \DateInterval('PT40S'));
239239
$doSet('qux', 'qux-val', new \DateInterval('PT80S'));
240240

241-
$cache->prune();
241+
$this->assertTrue($cache->prune());
242242
$this->assertFalse($this->isPruned($cache, 'foo'));
243243
$this->assertFalse($this->isPruned($cache, 'bar'));
244244
$this->assertFalse($this->isPruned($cache, 'baz'));
245245
$this->assertFalse($this->isPruned($cache, 'qux'));
246246

247247
sleep(30);
248-
$cache->prune();
248+
$this->assertTrue($cache->prune());
249249
$this->assertFalse($this->isPruned($cache, 'foo'));
250250
$this->assertTrue($this->isPruned($cache, 'bar'));
251251
$this->assertFalse($this->isPruned($cache, 'baz'));
252252
$this->assertFalse($this->isPruned($cache, 'qux'));
253253

254254
sleep(30);
255-
$cache->prune();
255+
$this->assertTrue($cache->prune());
256256
$this->assertFalse($this->isPruned($cache, 'foo'));
257257
$this->assertTrue($this->isPruned($cache, 'baz'));
258258
$this->assertFalse($this->isPruned($cache, 'qux'));
259259

260260
sleep(30);
261-
$cache->prune();
261+
$this->assertTrue($cache->prune());
262262
$this->assertFalse($this->isPruned($cache, 'foo'));
263263
$this->assertTrue($this->isPruned($cache, 'qux'));
264264
}

src/Symfony/Component/DependencyInjection/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

src/Symfony/Component/DependencyInjection/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()

src/Symfony/Component/HttpClient/Internal/ClientState.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ class ClientState
2222
{
2323
public $handlesActivity = [];
2424
public $openHandles = [];
25+
public $lastTimeout;
2526
}

src/Symfony/Component/HttpClient/Response/AsyncResponse.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ public function __construct(HttpClientInterface $client, string $method, string
5757
}
5858
$this->response = $client->request($method, $url, ['buffer' => false] + $options);
5959
$this->passthru = $passthru;
60-
$this->initializer = static function (self $response) {
60+
$this->initializer = static function (self $response, float $timeout = null) {
6161
if (null === $response->shouldBuffer) {
6262
return false;
6363
}
6464

6565
while (true) {
66-
foreach (self::stream([$response]) as $chunk) {
66+
foreach (self::stream([$response], $timeout) as $chunk) {
6767
if ($chunk->isTimeout() && $response->passthru) {
6868
foreach (self::passthru($response->client, $response, new ErrorChunk($response->offset, new TransportException($chunk->getError()))) as $chunk) {
6969
if ($chunk->isFirst()) {
@@ -179,6 +179,7 @@ public function __destruct()
179179

180180
if ($this->initializer && null === $this->getInfo('error')) {
181181
try {
182+
self::initialize($this, -0.0);
182183
$this->getHeaders(true);
183184
} catch (HttpExceptionInterface $httpException) {
184185
// no-op

0 commit comments

Comments
 (0)
0