Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 789448b

Browse files
Merge branch '4.3' into 4.4
* 4.3: Re-enable push support for HttpClient [DependencyInjection] Accept existing interfaces as valid named args Fixed incompatibility between ServiceSubscriberTrait and classes with protected $container property
2 parents 9c3345f + 6ea7f30 commit 789448b

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function processValue($value, $isRoot = false)
5353
$parameters = $r->getParameters();
5454
}
5555

56-
if (isset($key[0]) && '$' !== $key[0] && !class_exists($key)) {
56+
if (isset($key[0]) && '$' !== $key[0] && !class_exists($key) && !interface_exists($key, false)) {
5757
throw new InvalidArgumentException(sprintf('Invalid service "%s": did you forget to add the "$" prefix to argument "%s"?', $this->currentId, $key));
5858
}
5959

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveNamedArgumentsPassTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Psr\Container\ContainerInterface;
1516
use Symfony\Component\DependencyInjection\Compiler\ResolveNamedArgumentsPass;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718
use Symfony\Component\DependencyInjection\Reference;
@@ -152,6 +153,19 @@ public function testTypedArgumentWithMissingDollar()
152153
$pass->process($container);
153154
}
154155

156+
public function testInterfaceTypedArgument()
157+
{
158+
$container = new ContainerBuilder();
159+
160+
$definition = $container->register(NamedArgumentsDummy::class, NamedArgumentsDummy::class);
161+
$definition->setArgument(ContainerInterface::class, $expected = new Reference('foo'));
162+
163+
$pass = new ResolveNamedArgumentsPass();
164+
$pass->process($container);
165+
166+
$this->assertSame($expected, $definition->getArgument(3));
167+
}
168+
155169
public function testResolvesMultipleArgumentsOfTheSameType()
156170
{
157171
$container = new ContainerBuilder();

src/Symfony/Component/DependencyInjection/Tests/Fixtures/NamedArgumentsDummy.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
namespace Symfony\Component\DependencyInjection\Tests\Fixtures;
44

5+
use Psr\Container\ContainerInterface;
6+
57
/**
68
* @author Kévin Dunglas <[email protected]>
79
*/
810
class NamedArgumentsDummy
911
{
10-
public function __construct(CaseSensitiveClass $c, $apiKey, $hostName)
12+
public function __construct(CaseSensitiveClass $c, $apiKey, $hostName, ContainerInterface $interface)
1113
{
1214
}
1315

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface
5858
*
5959
* @see HttpClientInterface::OPTIONS_DEFAULTS for available options
6060
*/
61-
public function __construct(array $defaultOptions = [], int $maxHostConnections = 6, int $maxPendingPushes = 0)
61+
public function __construct(array $defaultOptions = [], int $maxHostConnections = 6, int $maxPendingPushes = 50)
6262
{
6363
if (!\extension_loaded('curl')) {
6464
throw new \LogicException('You cannot use the "Symfony\Component\HttpClient\CurlHttpClient" as the "curl" extension is not installed.');

src/Symfony/Contracts/Service/ServiceSubscriberTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
trait ServiceSubscriberTrait
2323
{
2424
/** @var ContainerInterface */
25-
private $container;
25+
protected $container;
2626

2727
public static function getSubscribedServices(): array
2828
{

0 commit comments

Comments
 (0)