23
23
use Http \Mock \Client as MockClient ;
24
24
use Psr \Http \Client \ClientInterface ;
25
25
use Psr \Http \Message \UriInterface ;
26
+ use Symfony \Component \Config \Definition \ConfigurationInterface ;
26
27
use Symfony \Component \Config \FileLocator ;
27
28
use Symfony \Component \DependencyInjection \Alias ;
28
29
use Symfony \Component \DependencyInjection \ChildDefinition ;
29
30
use Symfony \Component \DependencyInjection \ContainerBuilder ;
30
31
use Symfony \Component \DependencyInjection \Definition ;
31
- use Symfony \Component \DependencyInjection \DefinitionDecorator ;
32
32
use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
33
33
use Symfony \Component \DependencyInjection \Reference ;
34
34
use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
@@ -382,14 +382,8 @@ private function configureClient(ContainerBuilder $container, $clientName, array
382
382
{
383
383
$ serviceId = 'httplug.client. ' .$ clientName ;
384
384
385
- if (method_exists ($ container , 'registerAliasForArgument ' )) {
386
- $ alias = $ container ->registerAliasForArgument ($ serviceId , HttpClient::class, $ clientName );
387
-
388
- $ interfaces = class_implements (HttpClient::class) ?? [];
389
- if (isset ($ interfaces [ClientInterface::class])) {
390
- $ container ->registerAliasForArgument ($ serviceId , ClientInterface::class, $ clientName );
391
- }
392
- }
385
+ $ container ->registerAliasForArgument ($ serviceId , HttpClient::class, $ clientName );
386
+ $ container ->registerAliasForArgument ($ serviceId , ClientInterface::class, $ clientName );
393
387
394
388
$ plugins = [];
395
389
foreach ($ arguments ['plugins ' ] as $ plugin ) {
@@ -530,7 +524,7 @@ private function configureAutoDiscoveryClients(ContainerBuilder $container, arra
530
524
/**
531
525
* {@inheritdoc}
532
526
*/
533
- public function getConfiguration (array $ config , ContainerBuilder $ container )
527
+ public function getConfiguration (array $ config , ContainerBuilder $ container ): ? ConfigurationInterface
534
528
{
535
529
return new Configuration ($ container ->getParameter ('kernel.debug ' ));
536
530
}
@@ -547,7 +541,7 @@ private function configurePlugin(ContainerBuilder $container, $serviceId, $plugi
547
541
{
548
542
$ pluginServiceId = $ serviceId .'.plugin. ' .$ pluginName ;
549
543
550
- $ definition = $ this -> createChildDefinition ('httplug.plugin. ' .$ pluginName );
544
+ $ definition = new ChildDefinition ('httplug.plugin. ' .$ pluginName );
551
545
552
546
$ this ->configurePluginByName ($ pluginName , $ definition , $ pluginConfig , $ container , $ pluginServiceId );
553
547
$ container ->setDefinition ($ pluginServiceId , $ definition );
@@ -564,7 +558,7 @@ private function configureVcrPlugin(ContainerBuilder $container, array $config,
564
558
$ recordId = $ prefix .'.record ' ;
565
559
566
560
if ('filesystem ' === $ recorder ) {
567
- $ recorderDefinition = $ this -> createChildDefinition ('httplug.plugin.vcr.recorder.filesystem ' );
561
+ $ recorderDefinition = new ChildDefinition ('httplug.plugin.vcr.recorder.filesystem ' );
568
562
$ recorderDefinition ->replaceArgument (0 , $ config ['fixtures_directory ' ]);
569
563
$ recorderId = $ prefix .'.recorder ' ;
570
564
@@ -573,7 +567,7 @@ private function configureVcrPlugin(ContainerBuilder $container, array $config,
573
567
574
568
if ('default ' === $ config ['naming_strategy ' ]) {
575
569
$ namingStrategyId = $ prefix .'.naming_strategy ' ;
576
- $ namingStrategy = $ this -> createChildDefinition ('httplug.plugin.vcr.naming_strategy.path ' );
570
+ $ namingStrategy = new ChildDefinition ('httplug.plugin.vcr.naming_strategy.path ' );
577
571
578
572
if (!empty ($ config ['naming_strategy_options ' ])) {
579
573
$ namingStrategy ->setArguments ([$ config ['naming_strategy_options ' ]]);
@@ -610,18 +604,4 @@ private function configureVcrPlugin(ContainerBuilder $container, array $config,
610
604
611
605
return $ plugins ;
612
606
}
613
-
614
- /**
615
- * BC for old Symfony versions. Remove this method and use new ChildDefinition directly when we drop support for Symfony 2.
616
- *
617
- * @param string $parent the parent service id
618
- *
619
- * @return ChildDefinition|DefinitionDecorator
620
- */
621
- private function createChildDefinition ($ parent )
622
- {
623
- $ definitionClass = class_exists (ChildDefinition::class) ? ChildDefinition::class : DefinitionDecorator::class;
624
-
625
- return new $ definitionClass ($ parent );
626
- }
627
607
}
0 commit comments