Merge branch '4.3' into 4.4
* 4.3: [FrameworkBundle] remove messenger cache if not enabled [HttpClient] Fix strict parsing of response status codes [DI] Suggest typed argument when binding fails with untyped argument
This commit is contained in:
commit
9198b9dc97
@ -313,6 +313,7 @@ class FrameworkExtension extends Extension
|
||||
$container->removeDefinition('console.command.messenger_failed_messages_retry');
|
||||
$container->removeDefinition('console.command.messenger_failed_messages_show');
|
||||
$container->removeDefinition('console.command.messenger_failed_messages_remove');
|
||||
$container->removeDefinition('cache.messenger.restart_workers_signal');
|
||||
}
|
||||
|
||||
if ($this->httpClientConfigEnabled = $this->isConfigEnabled($container, $config['http_client'])) {
|
||||
|
@ -425,6 +425,7 @@
|
||||
<xsd:element name="bus" type="messenger_bus" minOccurs="0" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="default-bus" type="xsd:string" />
|
||||
<xsd:attribute name="enabled" type="xsd:boolean" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="messenger_serializer">
|
||||
|
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'messenger' => false,
|
||||
]);
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:messenger enabled="false" />
|
||||
</framework:config>
|
||||
</container>
|
@ -0,0 +1,2 @@
|
||||
framework:
|
||||
messenger: false
|
@ -668,9 +668,23 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertTrue($container->hasDefinition('web_link.add_link_header_listener'));
|
||||
}
|
||||
|
||||
public function testMessengerServicesRemovedWhenDisabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('messenger_disabled');
|
||||
$this->assertFalse($container->hasDefinition('console.command.messenger_consume_messages'));
|
||||
$this->assertFalse($container->hasDefinition('console.command.messenger_debug'));
|
||||
$this->assertFalse($container->hasDefinition('console.command.messenger_stop_workers'));
|
||||
$this->assertFalse($container->hasDefinition('console.command.messenger_setup_transports'));
|
||||
$this->assertFalse($container->hasDefinition('console.command.messenger_failed_messages_retry'));
|
||||
$this->assertFalse($container->hasDefinition('console.command.messenger_failed_messages_show'));
|
||||
$this->assertFalse($container->hasDefinition('console.command.messenger_failed_messages_remove'));
|
||||
$this->assertFalse($container->hasDefinition('cache.messenger.restart_workers_signal'));
|
||||
}
|
||||
|
||||
public function testMessenger()
|
||||
{
|
||||
$container = $this->createContainerFromFile('messenger');
|
||||
$this->assertTrue($container->hasDefinition('console.command.messenger_consume_messages'));
|
||||
$this->assertTrue($container->hasAlias('message_bus'));
|
||||
$this->assertTrue($container->getAlias('message_bus')->isPublic());
|
||||
$this->assertTrue($container->hasAlias('messenger.default_bus'));
|
||||
|
@ -114,6 +114,8 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
return parent::processValue($value, $isRoot);
|
||||
}
|
||||
|
||||
$bindingNames = [];
|
||||
|
||||
foreach ($bindings as $key => $binding) {
|
||||
list($bindingValue, $bindingId, $used, $bindingType, $file) = $binding->getValues();
|
||||
if ($used) {
|
||||
@ -123,7 +125,11 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
$this->unusedBindings[$bindingId] = [$key, $this->currentId, $bindingType, $file];
|
||||
}
|
||||
|
||||
if (preg_match('/^(?:(?:array|bool|float|int|string) )?\$/', $key)) {
|
||||
if (preg_match('/^(?:(?:array|bool|float|int|string|([^ $]++)) )\$/', $key, $m)) {
|
||||
$bindingNames[substr($key, \strlen($m[0]))] = $binding;
|
||||
}
|
||||
|
||||
if (!isset($m[1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -184,11 +190,17 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$typeHint || '\\' !== $typeHint[0] || !isset($bindings[$typeHint = substr($typeHint, 1)])) {
|
||||
if ($typeHint && '\\' === $typeHint[0] && isset($bindings[$typeHint = substr($typeHint, 1)])) {
|
||||
$arguments[$key] = $this->getBindingValue($bindings[$typeHint]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$arguments[$key] = $this->getBindingValue($bindings[$typeHint]);
|
||||
if (isset($bindingNames[$parameter->name])) {
|
||||
$bindingKey = array_search($binding, $bindings, true);
|
||||
$argumentType = substr($bindingKey, 0, strpos($bindingKey, ' '));
|
||||
$this->errorMessages[] = sprintf('Did you forget to add the type "%s" to argument "$%s" of method "%s::%s()"?', $argumentType, $parameter->name, $reflectionMethod->class, $reflectionMethod->name);
|
||||
}
|
||||
}
|
||||
|
||||
if ($arguments !== $call[1]) {
|
||||
|
@ -20,6 +20,7 @@ use Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass;
|
||||
use Symfony\Component\DependencyInjection\Compiler\ResolveBindingsPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy;
|
||||
@ -169,4 +170,19 @@ class ResolveBindingsPassTest extends TestCase
|
||||
|
||||
$this->assertSame([1 => 'bar'], $container->getDefinition(NamedArgumentsDummy::class)->getArguments());
|
||||
}
|
||||
|
||||
public function testEmptyBindingTypehint()
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Did you forget to add the type "string" to argument "$apiKey" of method "Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy::__construct()"?');
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$bindings = [
|
||||
'string $apiKey' => new BoundArgument('foo'),
|
||||
];
|
||||
$definition = $container->register(NamedArgumentsDummy::class, NamedArgumentsDummy::class);
|
||||
$definition->setBindings($bindings);
|
||||
$pass = new ResolveBindingsPass();
|
||||
$pass->process($container);
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ trait ResponseTrait
|
||||
private static function addResponseHeaders(array $responseHeaders, array &$info, array &$headers, string &$debug = ''): void
|
||||
{
|
||||
foreach ($responseHeaders as $h) {
|
||||
if (11 <= \strlen($h) && '/' === $h[4] && preg_match('#^HTTP/\d+(?:\.\d+)? ([12345]\d\d) .*#', $h, $m)) {
|
||||
if (11 <= \strlen($h) && '/' === $h[4] && preg_match('#^HTTP/\d+(?:\.\d+)? ([12345]\d\d)(?: |$)#', $h, $m)) {
|
||||
if ($headers) {
|
||||
$debug .= "< \r\n";
|
||||
$headers = [];
|
||||
|
Reference in New Issue
Block a user