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
This commit is contained in:
commit
789448b65c
@ -53,7 +53,7 @@ class ResolveNamedArgumentsPass extends AbstractRecursivePass
|
|||||||
$parameters = $r->getParameters();
|
$parameters = $r->getParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($key[0]) && '$' !== $key[0] && !class_exists($key)) {
|
if (isset($key[0]) && '$' !== $key[0] && !class_exists($key) && !interface_exists($key, false)) {
|
||||||
throw new InvalidArgumentException(sprintf('Invalid service "%s": did you forget to add the "$" prefix to argument "%s"?', $this->currentId, $key));
|
throw new InvalidArgumentException(sprintf('Invalid service "%s": did you forget to add the "$" prefix to argument "%s"?', $this->currentId, $key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
|
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
use Symfony\Component\DependencyInjection\Compiler\ResolveNamedArgumentsPass;
|
use Symfony\Component\DependencyInjection\Compiler\ResolveNamedArgumentsPass;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
@ -152,6 +153,19 @@ class ResolveNamedArgumentsPassTest extends TestCase
|
|||||||
$pass->process($container);
|
$pass->process($container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testInterfaceTypedArgument()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
|
$definition = $container->register(NamedArgumentsDummy::class, NamedArgumentsDummy::class);
|
||||||
|
$definition->setArgument(ContainerInterface::class, $expected = new Reference('foo'));
|
||||||
|
|
||||||
|
$pass = new ResolveNamedArgumentsPass();
|
||||||
|
$pass->process($container);
|
||||||
|
|
||||||
|
$this->assertSame($expected, $definition->getArgument(3));
|
||||||
|
}
|
||||||
|
|
||||||
public function testResolvesMultipleArgumentsOfTheSameType()
|
public function testResolvesMultipleArgumentsOfTheSameType()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\DependencyInjection\Tests\Fixtures;
|
namespace Symfony\Component\DependencyInjection\Tests\Fixtures;
|
||||||
|
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||||
*/
|
*/
|
||||||
class NamedArgumentsDummy
|
class NamedArgumentsDummy
|
||||||
{
|
{
|
||||||
public function __construct(CaseSensitiveClass $c, $apiKey, $hostName)
|
public function __construct(CaseSensitiveClass $c, $apiKey, $hostName, ContainerInterface $interface)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface
|
|||||||
*
|
*
|
||||||
* @see HttpClientInterface::OPTIONS_DEFAULTS for available options
|
* @see HttpClientInterface::OPTIONS_DEFAULTS for available options
|
||||||
*/
|
*/
|
||||||
public function __construct(array $defaultOptions = [], int $maxHostConnections = 6, int $maxPendingPushes = 0)
|
public function __construct(array $defaultOptions = [], int $maxHostConnections = 6, int $maxPendingPushes = 50)
|
||||||
{
|
{
|
||||||
if (!\extension_loaded('curl')) {
|
if (!\extension_loaded('curl')) {
|
||||||
throw new \LogicException('You cannot use the "Symfony\Component\HttpClient\CurlHttpClient" as the "curl" extension is not installed.');
|
throw new \LogicException('You cannot use the "Symfony\Component\HttpClient\CurlHttpClient" as the "curl" extension is not installed.');
|
||||||
|
@ -22,7 +22,7 @@ use Psr\Container\ContainerInterface;
|
|||||||
trait ServiceSubscriberTrait
|
trait ServiceSubscriberTrait
|
||||||
{
|
{
|
||||||
/** @var ContainerInterface */
|
/** @var ContainerInterface */
|
||||||
private $container;
|
protected $container;
|
||||||
|
|
||||||
public static function getSubscribedServices(): array
|
public static function getSubscribedServices(): array
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user