diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php
index 11e97756b0037..32b70a0829efb 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php
@@ -192,7 +192,7 @@ private function assertDescription($expectedDescription, $describedObject, array
$this->getDescriptor()->describe($output, $describedObject, $options);
if ('json' === $this->getFormat()) {
- $this->assertEquals(json_decode($expectedDescription), json_decode($output->fetch()));
+ $this->assertEquals(json_encode(json_decode($expectedDescription), JSON_PRETTY_PRINT), json_encode(json_decode($output->fetch()), JSON_PRETTY_PRINT));
} else {
$this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch())));
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php
index b89902fe54039..0c0363c482bab 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php
@@ -14,7 +14,6 @@
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@@ -121,10 +120,6 @@ public static function getContainerDefinitions()
new Reference('definition_2'),
)))
->addArgument(new ClosureProxyArgument('definition1', 'get'))
- ->addArgument(new ServiceLocatorArgument(array(
- 'def1' => new Reference('definition_1'),
- 'def2' => new Reference('definition_2'),
- )))
->setFactory(array('Full\\Qualified\\FactoryClass', 'get')),
'definition_2' => $definition2
->setPublic(false)
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php
index fc419638ccf2f..9a3a12dd50d29 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php
@@ -13,9 +13,11 @@
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConstraintValidatorsPass;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
+use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\ServiceLocator;
class AddConstraintValidatorsPassTest extends TestCase
{
@@ -23,7 +25,7 @@ public function testThatConstraintValidatorServicesAreProcessed()
{
$container = new ContainerBuilder();
$validatorFactory = $container->register('validator.validator_factory')
- ->setArguments(array(new ServiceLocatorArgument(array())));
+ ->addArgument(array());
$container->register('my_constraint_validator_service1', Validator1::class)
->addTag('validator.constraint_validator', array('alias' => 'my_constraint_validator_alias1'));
@@ -36,11 +38,11 @@ public function testThatConstraintValidatorServicesAreProcessed()
$addConstraintValidatorsPass = new AddConstraintValidatorsPass();
$addConstraintValidatorsPass->process($container);
- $this->assertEquals(new ServiceLocatorArgument(array(
- Validator1::class => new Reference('my_constraint_validator_service1'),
- 'my_constraint_validator_alias1' => new Reference('my_constraint_validator_service1'),
- Validator2::class => new Reference('my_constraint_validator_service2'),
- )), $validatorFactory->getArgument(0));
+ $this->assertEquals((new Definition(ServiceLocator::class, array(array(
+ Validator1::class => new ServiceClosureArgument(new Reference('my_constraint_validator_service1')),
+ 'my_constraint_validator_alias1' => new ServiceClosureArgument(new Reference('my_constraint_validator_service1')),
+ Validator2::class => new ServiceClosureArgument(new Reference('my_constraint_validator_service2')),
+ ))))->addTag('container.service_locator'), $validatorFactory->getArgument(0));
}
public function testThatCompilerPassIsIgnoredIfThereIsNoConstraintValidatorFactoryDefinition()
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/FormPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/FormPassTest.php
index 15c4ff9c9f25e..0db1d1153a373 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/FormPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/FormPassTest.php
@@ -14,10 +14,11 @@
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FormPass;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
+use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\Form\AbstractType;
/**
@@ -49,10 +50,10 @@ public function testAddTaggedTypes()
$extDefinition = $container->getDefinition('form.extension');
$this->assertEquals(
- new ServiceLocatorArgument(array(
- __CLASS__.'_Type1' => new Reference('my.type1'),
- __CLASS__.'_Type2' => new Reference('my.type2'),
- )),
+ (new Definition(ServiceLocator::class, array(array(
+ __CLASS__.'_Type1' => new ServiceClosureArgument(new Reference('my.type1')),
+ __CLASS__.'_Type2' => new ServiceClosureArgument(new Reference('my.type2')),
+ ))))->addTag('container.service_locator'),
$extDefinition->getArgument(0)
);
}
@@ -196,7 +197,7 @@ private function createExtensionDefinition()
{
$definition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension');
$definition->setArguments(array(
- new ServiceLocatorArgument(array()),
+ array(),
array(),
new IteratorArgument(array()),
));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
index 13ff7e08d44c1..1163fc6204331 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
@@ -15,6 +15,7 @@
use Symfony\Bundle\FullStack;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
+use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConstraintValidatorsPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Cache\Adapter\ApcuAdapter;
@@ -907,7 +908,7 @@ protected function createContainerFromFile($file, $data = array(), $resetCompile
$container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array());
}
- $container->getCompilerPassConfig()->setBeforeRemovingPasses(array(new AddAnnotationsCachedReaderPass()));
+ $container->getCompilerPassConfig()->setBeforeRemovingPasses(array(new AddAnnotationsCachedReaderPass(), new AddConstraintValidatorsPass()));
$container->compile();
return self::$containerCache[$cacheKey] = $container;
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json
index 241cade9088ef..7c43445239fb9 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json
@@ -64,17 +64,7 @@
"id": "definition1"
},
"get"
- ],
- {
- "def1": {
- "type": "service",
- "id": "definition_1"
- },
- "def2": {
- "type": "service",
- "id": "definition_2"
- }
- }
+ ]
],
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml
index 930fc5204a9ee..f74ad13d7be74 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml
@@ -24,10 +24,6 @@
-
-
-
-
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json
index 070f68976ef0c..ad4ada52a9cd4 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json
@@ -62,17 +62,7 @@
"id": "definition1"
},
"get"
- ],
- {
- "def1": {
- "type": "service",
- "id": "definition_1"
- },
- "def2": {
- "type": "service",
- "id": "definition_2"
- }
- }
+ ]
],
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt
index b0fd0acd7aa32..6f02db65ed764 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt
@@ -18,6 +18,5 @@
Array (3 element(s))
Iterator (2 element(s))
ClosureProxy(Service(definition1)::get())
- ServiceLocator (2 service(s))
---------------- -------------------------------------------
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml
index cc8f6421a7389..85935808c6b90 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml
@@ -21,8 +21,4 @@
-
-
-
-
diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
index a04e29973a465..6db601e3ccf98 100644
--- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
@@ -17,12 +17,14 @@
use Symfony\Component\Console\Application;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
+use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\ChildDefinition;
+use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Security\Core\Authorization\ExpressionLanguage;
@@ -260,10 +262,10 @@ private function createFirewalls($config, ContainerBuilder $container)
->replaceArgument(2, new Reference($configId))
;
- $contextRefs[$contextId] = new Reference($contextId);
+ $contextRefs[$contextId] = new ServiceClosureArgument(new Reference($contextId));
$map[$contextId] = $matcher;
}
- $mapDef->replaceArgument(0, new ServiceLocatorArgument($contextRefs));
+ $mapDef->replaceArgument(0, (new Definition(ServiceLocator::class, array($contextRefs)))->addTag('container.service_locator'));
$mapDef->replaceArgument(1, new IteratorArgument($map));
// add authentication providers to authentication manager
diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php
index bfefb98e15eed..7f4a87a945d6f 100644
--- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php
+++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php
@@ -11,10 +11,12 @@
namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
+use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\Definition;
+use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* Registers Twig runtime services.
@@ -36,9 +38,9 @@ public function process(ContainerBuilder $container)
continue;
}
- $mapping[$def->getClass()] = new Reference($id);
+ $mapping[$def->getClass()] = new ServiceClosureArgument(new Reference($id));
}
- $definition->replaceArgument(0, new ServiceLocatorArgument($mapping));
+ $definition->replaceArgument(0, (new Definition(ServiceLocator::class, array($mapping)))->addTag('container.service_locator'));
}
}
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php
index ad54b9276716c..ef9445356a811 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php
@@ -244,11 +244,11 @@ public function testRuntimeLoader()
$container->compile();
$loader = $container->getDefinition('twig.runtime_loader');
- $args = $loader->getArgument(0)->getValues();
+ $args = $loader->getArgument(0)->getArgument(0);
$this->assertArrayHasKey('Symfony\Bridge\Twig\Form\TwigRenderer', $args);
$this->assertArrayHasKey('FooClass', $args);
- $this->assertContains('twig.form.renderer', $args);
- $this->assertContains('foo', $args);
+ $this->assertEquals('twig.form.renderer', $args['Symfony\Bridge\Twig\Form\TwigRenderer']->getValues()[0]);
+ $this->assertEquals('foo', $args['FooClass']->getValues()[0]);
}
private function createContainer()
diff --git a/src/Symfony/Component/DependencyInjection/Argument/ServiceClosureArgument.php b/src/Symfony/Component/DependencyInjection/Argument/ServiceClosureArgument.php
index 2d52ad91919d2..466e63d215429 100644
--- a/src/Symfony/Component/DependencyInjection/Argument/ServiceClosureArgument.php
+++ b/src/Symfony/Component/DependencyInjection/Argument/ServiceClosureArgument.php
@@ -18,8 +18,6 @@
* Represents a service wrapped in a memoizing closure.
*
* @author Nicolas Grekas
- *
- * @experimental in version 3.3
*/
class ServiceClosureArgument implements ArgumentInterface
{
diff --git a/src/Symfony/Component/DependencyInjection/Argument/ServiceLocatorArgument.php b/src/Symfony/Component/DependencyInjection/Argument/ServiceLocatorArgument.php
deleted file mode 100644
index b53545e12b41c..0000000000000
--- a/src/Symfony/Component/DependencyInjection/Argument/ServiceLocatorArgument.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\DependencyInjection\Argument;
-
-use Symfony\Component\DependencyInjection\Reference;
-use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
-
-/**
- * Represents a service locator able to lazy load a given range of services.
- *
- * @author Robin Chalas
- */
-class ServiceLocatorArgument implements ArgumentInterface
-{
- private $values;
-
- /**
- * @param Reference[] $values An array of references indexed by identifier
- */
- public function __construct(array $values)
- {
- $this->setValues($values);
- }
-
- public function getValues()
- {
- return $this->values;
- }
-
- public function setValues(array $values)
- {
- foreach ($values as $v) {
- if (!$v instanceof Reference && null !== $v) {
- throw new InvalidArgumentException('Values of a ServiceLocatorArgument must be Reference objects.');
- }
- }
-
- $this->values = $values;
- }
-}
diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md
index c61741500fdb0..fd48aff1adfc7 100644
--- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md
+++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md
@@ -4,10 +4,10 @@ CHANGELOG
3.3.0
-----
+ * added "container.service_locator" tag for defining service-locator services
* added anonymous services support in YAML configuration files using the `!service` tag.
- * [EXPERIMENTAL] added "TypedReference" and "ServiceClosureArgument" for creating service-locator services
+ * added "TypedReference" and "ServiceClosureArgument" for creating service-locator services
* [EXPERIMENTAL] added "instanceof" section for local interface-defined configs
- * added "service-locator" argument for lazy loading a set of identified values and services
* [EXPERIMENTAL] added prototype services for PSR4-based discovery and registration
* added `ContainerBuilder::getReflectionClass()` for retrieving and tracking reflection class info
* deprecated `ContainerBuilder::getClassResource()`, use `ContainerBuilder::getReflectionClass()` or `ContainerBuilder::addObjectResource()` instead
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
index f69e76707eb3e..d1168cf5960a4 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
@@ -49,6 +49,7 @@ public function __construct()
$this->optimizationPasses = array(array(
new ExtensionCompilerPass(),
new ResolveDefinitionTemplatesPass(),
+ new ServiceLocatorTagPass(),
new DecoratorServicePass(),
new ResolveParameterPlaceHoldersPass(),
new ResolveFactoryClassPass(),
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php
new file mode 100644
index 0000000000000..e8fd8379a4fe7
--- /dev/null
+++ b/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php
@@ -0,0 +1,54 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection\Compiler;
+
+use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
+use Symfony\Component\DependencyInjection\Definition;
+use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\ServiceLocator;
+
+/**
+ * Applies the "container.service_locator" tag by wrapping references into ServiceClosureArgument instances.
+ *
+ * @author Nicolas Grekas
+ */
+class ServiceLocatorTagPass extends AbstractRecursivePass
+{
+ protected function processValue($value, $isRoot = false)
+ {
+ if (!$value instanceof Definition || !$value->hasTag('container.service_locator')) {
+ return parent::processValue($value, $isRoot);
+ }
+
+ if (!$value->getClass()) {
+ $value->setClass(ServiceLocator::class);
+ }
+
+ $arguments = $value->getArguments();
+ if (!isset($arguments[0]) || !is_array($arguments[0])) {
+ throw new InvalidArgumentException(sprintf('Invalid definition for service "%s": an array of references is expected as first argument when the "container.service_locator" tag is set.', $this->currentId));
+ }
+
+ foreach ($arguments[0] as $k => $v) {
+ if ($v instanceof ServiceClosureArgument) {
+ continue;
+ }
+ if (!$v instanceof Reference) {
+ throw new InvalidArgumentException(sprintf('Invalid definition for service "%s": an array of references is expected as first argument when the "container.service_locator" tag is set, "%s" found for key "%s".', $this->currentId, is_object($v) ? get_class($v) : gettype($v), $k));
+ }
+ $arguments[0][$k] = new ServiceClosureArgument($v);
+ }
+
+ return $value->setArguments($arguments);
+ }
+}
diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
index e8f33fc8ad619..1b98f937470d0 100644
--- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
+++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
@@ -16,7 +16,6 @@
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\Compiler\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
@@ -1146,18 +1145,6 @@ public function resolveServices($value)
$value = function () use ($reference) {
return $this->resolveServices($reference);
};
- } elseif ($value instanceof ServiceLocatorArgument) {
- $parameterBag = $this->getParameterBag();
- $services = array();
- foreach ($value->getValues() as $k => $v) {
- if ($v && $v->getInvalidBehavior() === ContainerInterface::IGNORE_ON_INVALID_REFERENCE && !$this->has((string) $v)) {
- continue;
- }
- $services[$k] = function () use ($v, $parameterBag) {
- return $this->resolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($v)));
- };
- }
- $value = new ServiceLocator($services);
} elseif ($value instanceof IteratorArgument) {
$parameterBag = $this->getParameterBag();
$value = new RewindableGenerator(function () use ($value, $parameterBag) {
diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
index c13b7a5fe3e19..6d13ec968e187 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
@@ -15,7 +15,6 @@
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\Variable;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -907,7 +906,6 @@ private function startClass($class, $baseClass, $namespace)
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
$bagClass
-use Symfony\Component\DependencyInjection\ServiceLocator;
/*{$this->docStar}
* $class.
@@ -1548,15 +1546,16 @@ private function dumpValue($value, $interpolate = true)
return sprintf('array(%s)', implode(', ', $code));
} elseif ($value instanceof ServiceClosureArgument) {
- return $this->dumpServiceClosure($value->getValues()[0], $interpolate, false);
- } elseif ($value instanceof ServiceLocatorArgument) {
- $code = "\n";
- foreach ($value->getValues() as $k => $v) {
- $code .= sprintf(" %s => %s,\n", $this->dumpValue($k, $interpolate), $this->dumpServiceClosure($v, $interpolate, true));
+ $value = $value->getValues()[0];
+ $code = $this->dumpValue($value, $interpolate);
+
+ if ($value instanceof TypedReference) {
+ $code = sprintf('$f = function (\\%s $v%s) { return $v; }; return $f(%s);', $value->getType(), ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $value->getInvalidBehavior() ? ' = null' : '', $code);
+ } else {
+ $code = sprintf('return %s;', $code);
}
- $code .= ' ';
- return sprintf('new ServiceLocator(array(%s))', $code);
+ return sprintf("function () {\n %s\n }", $code);
} elseif ($value instanceof IteratorArgument) {
$countCode = array();
$countCode[] = 'function () {';
@@ -1692,23 +1691,6 @@ private function dumpValue($value, $interpolate = true)
return $this->export($value);
}
- private function dumpServiceClosure(Reference $reference = null, $interpolate, $oneLine)
- {
- $code = $this->dumpValue($reference, $interpolate);
-
- if ($reference instanceof TypedReference) {
- $code = sprintf('$f = function (\\%s $v%s) { return $v; }; return $f(%s);', $reference->getType(), ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior() ? ' = null' : '', $code);
- } else {
- $code = sprintf('return %s;', $code);
- }
-
- if ($oneLine) {
- return sprintf('function () { %s }', $code);
- }
-
- return sprintf("function () {\n %s\n }", $code);
- }
-
/**
* Dumps a string to a literal (aka PHP Code) class value.
*
diff --git a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
index 1490e97c96a3e..1cb7b5b0b6f51 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
@@ -14,7 +14,6 @@
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\DependencyInjection\Reference;
@@ -296,9 +295,6 @@ private function convertParameters(array $parameters, $type, \DOMElement $parent
if (is_array($value)) {
$element->setAttribute('type', 'collection');
$this->convertParameters($value, $type, $element, 'key');
- } elseif ($value instanceof ServiceLocatorArgument) {
- $element->setAttribute('type', 'service-locator');
- $this->convertParameters($value->getValues(), $type, $element);
} elseif ($value instanceof IteratorArgument) {
$element->setAttribute('type', 'iterator');
$this->convertParameters($value->getValues(), $type, $element, 'key');
diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
index d708ea5f7eaa9..7301511567de2 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
@@ -18,7 +18,6 @@
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Parameter;
@@ -263,8 +262,6 @@ private function dumpValue($value)
$tag = 'iterator';
} elseif ($value instanceof ClosureProxyArgument) {
$tag = 'closure_proxy';
- } elseif ($value instanceof ServiceLocatorArgument) {
- $tag = 'service_locator';
} else {
throw new RuntimeException(sprintf('Unspecified Yaml tag for type "%s".', get_class($value)));
}
diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
index bb99fbc787bb6..171cc9a4664e5 100644
--- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
+++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
@@ -16,7 +16,6 @@
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Reference;
@@ -488,15 +487,6 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true,
case 'iterator':
$arguments[$key] = new IteratorArgument($this->getArgumentsAsPhp($arg, $name, false));
break;
- case 'service-locator':
- $values = $this->getArgumentsAsPhp($arg, $name, false);
- foreach ($values as $v) {
- if (!$v instanceof Reference) {
- throw new InvalidArgumentException('"service-locator" argument values must be services.');
- }
- }
- $arguments[$key] = new ServiceLocatorArgument($values);
- break;
case 'string':
$arguments[$key] = $arg->nodeValue;
break;
diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
index 4de60a94657de..2d74456cac41d 100644
--- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
+++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
@@ -15,7 +15,6 @@
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
@@ -671,19 +670,6 @@ private function resolveServices($value, $file, $isParameter = false)
return new IteratorArgument($this->resolveServices($argument, $file, $isParameter));
}
- if ('service_locator' === $value->getTag()) {
- if (!is_array($argument)) {
- throw new InvalidArgumentException('"!service_locator" tag only accepts mappings.');
- }
-
- foreach ($argument as $v) {
- if (!is_string($v) || 0 !== strpos($v[0], '@') || 0 === strpos($v[0], '@@')) {
- throw new InvalidArgumentException('"!service_locator" tagged values must be {key: @service} mappings.');
- }
- }
-
- return new ServiceLocatorArgument($this->resolveServices($argument, $file, $isParameter));
- }
if ('closure_proxy' === $value->getTag()) {
if (!is_array($argument) || array(0, 1) !== array_keys($argument) || !is_string($argument[0]) || !is_string($argument[1]) || 0 !== strpos($argument[0], '@') || 0 === strpos($argument[0], '@@')) {
throw new InvalidArgumentException('"!closure_proxy" tagged values must be arrays of [@service, method].');
diff --git a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
index d87e0ef196425..ce3b04b57ad4d 100644
--- a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
+++ b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
@@ -262,7 +262,6 @@
-
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Argument/ServiceLocatorArgumentTest.php b/src/Symfony/Component/DependencyInjection/Tests/Argument/ServiceLocatorArgumentTest.php
deleted file mode 100644
index 040ca7fe34e73..0000000000000
--- a/src/Symfony/Component/DependencyInjection/Tests/Argument/ServiceLocatorArgumentTest.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\DependencyInjection\Tests\Argument;
-
-use PHPUnit\Framework\TestCase;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
-use Symfony\Component\DependencyInjection\Reference;
-
-class ServiceLocatorArgumentTest extends TestCase
-{
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
- * @expectedExceptionMessage Values of a ServiceLocatorArgument must be Reference objects.
- */
- public function testThrowsOnNonReferenceValues()
- {
- new ServiceLocatorArgument(array('foo' => 'bar'));
- }
-
- public function testAcceptsReferencesOrNulls()
- {
- $locator = new ServiceLocatorArgument($values = array('foo' => new Reference('bar'), 'bar' => null));
-
- $this->assertSame($values, $locator->getValues());
- }
-}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
index 67890faacad54..7b11e60313e55 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
@@ -24,7 +24,6 @@
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\Container;
@@ -471,24 +470,6 @@ public function testCreateServiceWithIteratorArgument()
$this->assertEquals(1, $i);
}
- public function testCreateServiceWithServiceLocatorArgument()
- {
- $builder = new ContainerBuilder();
- $builder->register('bar', 'stdClass');
- $builder
- ->register('lazy_context', 'LazyContext')
- ->setArguments(array(new ServiceLocatorArgument(array('bar' => new Reference('bar'), 'invalid' => new Reference('invalid', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))))
- ;
-
- $lazyContext = $builder->get('lazy_context');
- $locator = $lazyContext->lazyValues;
-
- $this->assertInstanceOf(ServiceLocator::class, $locator);
- $this->assertInstanceOf('stdClass', $locator->get('bar'));
- $this->assertFalse($locator->has('invalid'));
- $this->assertSame($locator->get('bar'), $locator('bar'), '->get() should be used when invoking ServiceLocator');
- }
-
/**
* @expectedException \RuntimeException
*/
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
index d03dcdc74aedd..aaecacfc445d0 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
@@ -17,7 +17,6 @@
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@@ -527,35 +526,6 @@ public function testCircularReferenceAllowanceForInlinedDefinitionsForLazyServic
$dumper->dump();
}
- public function testServiceLocatorArgumentProvideServiceLocator()
- {
- require_once self::$fixturesPath.'/includes/classes.php';
-
- $container = new ContainerBuilder();
- $container->register('lazy_referenced', 'stdClass');
- $container
- ->register('lazy_context', 'LazyContext')
- ->setArguments(array(new ServiceLocatorArgument(array('lazy1' => new Reference('lazy_referenced'), 'lazy2' => new Reference('lazy_referenced'), 'container' => new Reference('service_container')))))
- ;
- $container->compile();
-
- $dumper = new PhpDumper($container);
- $dump = $dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Locator_Argument_Provide_Service_Locator'));
- $this->assertStringEqualsFile(self::$fixturesPath.'/php/services_locator_argument.php', $dump);
-
- require_once self::$fixturesPath.'/php/services_locator_argument.php';
-
- $container = new \Symfony_DI_PhpDumper_Test_Locator_Argument_Provide_Service_Locator();
- $lazyContext = $container->get('lazy_context');
-
- $this->assertInstanceOf(ServiceLocator::class, $lazyContext->lazyValues);
- $this->assertSame($container, $lazyContext->lazyValues->get('container'));
- $this->assertInstanceOf('stdClass', $lazy1 = $lazyContext->lazyValues->get('lazy1'));
- $this->assertInstanceOf('stdClass', $lazy2 = $lazyContext->lazyValues->get('lazy2'));
- $this->assertSame($lazy1, $lazy2);
- $this->assertFalse($lazyContext->lazyValues->has('lazy_referenced'), '->has() returns false for the original service id, only the key can be used');
- }
-
public function testLazyArgumentProvideGenerator()
{
require_once self::$fixturesPath.'/includes/classes.php';
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php
index c8292c5e0520e..6d1cc0cb3a9f2 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php
@@ -5,7 +5,6 @@
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
@@ -145,13 +144,5 @@
->register('closure_proxy', 'BarClass')
->setArguments(array(new ClosureProxyArgument('closure_proxy', 'getBaz')))
;
-$container
- ->register('service_locator', 'Bar')
- ->setArguments(array(new ServiceLocatorArgument(array(
- 'bar' => new Reference('bar'),
- 'invalid' => new Reference('invalid', ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
- 'container' => new Reference('service_container'),
- ))))
-;
return $container;
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot
index 2c84476b7b575..47cf9283043c6 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot
@@ -30,7 +30,6 @@ digraph sc {
node_lazy_context [label="lazy_context\nLazyContext\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_lazy_context_ignore_invalid_ref [label="lazy_context_ignore_invalid_ref\nLazyContext\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_closure_proxy [label="closure_proxy\nBarClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
- node_service_locator [label="service_locator\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_foo2 [label="foo2\n\n", shape=record, fillcolor="#ff9999", style="filled"];
node_foo3 [label="foo3\n\n", shape=record, fillcolor="#ff9999", style="filled"];
node_foobaz [label="foobaz\n\n", shape=record, fillcolor="#ff9999", style="filled"];
@@ -53,7 +52,4 @@ digraph sc {
node_lazy_context_ignore_invalid_ref -> node_foo_baz [label="" style="filled" color="#9999ff"];
node_lazy_context_ignore_invalid_ref -> node_invalid [label="" style="filled" color="#9999ff"];
node_closure_proxy -> node_closure_proxy [label="" style="filled" color="#9999ff"];
- node_service_locator -> node_bar [label="" style="filled" color="#9999ff"];
- node_service_locator -> node_invalid [label="" style="filled" color="#9999ff"];
- node_service_locator -> node_service_container [label="" style="filled" color="#9999ff"];
}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php
index 2c6e65b3e7c47..b4e1a0ba93a19 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php
@@ -8,7 +8,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* Container.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php
index d85d8936dbe8a..664461fc29adf 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php
index b6118a84a38fd..943bf4aeb5836 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php
index 973f8cd54ae8b..a9053f2c8a03a 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php
index 2710f9b12d8ab..7899e088c3372 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php
index 9e5ff196334c6..ace344ab057d6 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php
index db4b6defb3d36..629d0749e3f01 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php
index dc46680572064..05d2bd68b2174 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services29.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services29.php
index cc4dccff8f072..faeb2d9051846 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services29.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services29.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* Symfony_DI_PhpDumper_Test_Overriden_Getters.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php
index e957125e64576..229969e0d3c37 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php
index 9a06d55f904de..ed4b9fa2c986c 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php
index 3eebf9508130f..76ccee02864e3 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php
index 0127399ff1cd5..aa1721315b502 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php
index 93fe0e5939fc1..2c2da3c0eb30e 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
@@ -59,7 +58,6 @@ public function __construct()
'new_factory' => 'getNewFactoryService',
'new_factory_service' => 'getNewFactoryServiceService',
'service_from_static_method' => 'getServiceFromStaticMethodService',
- 'service_locator' => 'getServiceLocatorService',
);
$this->privates = array(
'configurator_service' => true,
@@ -410,23 +408,6 @@ protected function getServiceFromStaticMethodService()
return $this->services['service_from_static_method'] = \Bar\FooClass::getInstance();
}
- /**
- * Gets the 'service_locator' service.
- *
- * This service is shared.
- * This method always returns the same instance of the service.
- *
- * @return \Bar A Bar instance
- */
- protected function getServiceLocatorService()
- {
- return $this->services['service_locator'] = new \Bar(new ServiceLocator(array(
- 'bar' => function () { return ${($_ = isset($this->services['bar']) ? $this->services['bar'] : $this->get('bar')) && false ?: '_'}; },
- 'invalid' => function () { return $this->get('invalid', ContainerInterface::NULL_ON_INVALID_REFERENCE); },
- 'container' => function () { return $this; },
- )));
- }
-
/**
* Gets the 'configurator_service' service.
*
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php
index 8c6d8a95355be..ed307f95a910a 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
@@ -55,7 +54,6 @@ public function __construct()
'method_call1' => 'getMethodCall1Service',
'new_factory_service' => 'getNewFactoryServiceService',
'service_from_static_method' => 'getServiceFromStaticMethodService',
- 'service_locator' => 'getServiceLocatorService',
);
$this->aliases = array(
'alias_for_alias' => 'foo',
@@ -398,22 +396,6 @@ protected function getServiceFromStaticMethodService()
return $this->services['service_from_static_method'] = \Bar\FooClass::getInstance();
}
- /**
- * Gets the 'service_locator' service.
- *
- * This service is shared.
- * This method always returns the same instance of the service.
- *
- * @return \Bar A Bar instance
- */
- protected function getServiceLocatorService()
- {
- return $this->services['service_locator'] = new \Bar(new ServiceLocator(array(
- 'bar' => function () { return ${($_ = isset($this->services['bar']) ? $this->services['bar'] : $this->get('bar')) && false ?: '_'}; },
- 'container' => function () { return $this; },
- )));
- }
-
/**
* {@inheritdoc}
*/
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_overriden_getters_with_constructor.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_overriden_getters_with_constructor.php
index 4329d9fdcdda0..40a0492c524ef 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_overriden_getters_with_constructor.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_overriden_getters_with_constructor.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* Symfony_DI_PhpDumper_Test_Overriden_Getters_With_Constructor.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_proxy_with_void_return_type.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_proxy_with_void_return_type.php
index b896cae4578c5..a7471d27d5aef 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_proxy_with_void_return_type.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_proxy_with_void_return_type.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php
index ebbc2ae1532e3..4548776124ef5 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator_argument.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator_argument.php
deleted file mode 100644
index 9859d372bd232..0000000000000
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator_argument.php
+++ /dev/null
@@ -1,89 +0,0 @@
-services = array();
- $this->normalizedIds = array(
- 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
- 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container',
- 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
- );
- $this->methodMap = array(
- 'lazy_context' => 'getLazyContextService',
- 'lazy_referenced' => 'getLazyReferencedService',
- );
-
- $this->aliases = array();
- }
-
- /**
- * {@inheritdoc}
- */
- public function compile()
- {
- throw new LogicException('You cannot compile a dumped frozen container.');
- }
-
- /**
- * {@inheritdoc}
- */
- public function isFrozen()
- {
- return true;
- }
-
- /**
- * Gets the 'lazy_context' service.
- *
- * This service is shared.
- * This method always returns the same instance of the service.
- *
- * @return \LazyContext A LazyContext instance
- */
- protected function getLazyContextService()
- {
- return $this->services['lazy_context'] = new \LazyContext(new ServiceLocator(array(
- 'lazy1' => function () { return ${($_ = isset($this->services['lazy_referenced']) ? $this->services['lazy_referenced'] : $this->get('lazy_referenced')) && false ?: '_'}; },
- 'lazy2' => function () { return ${($_ = isset($this->services['lazy_referenced']) ? $this->services['lazy_referenced'] : $this->get('lazy_referenced')) && false ?: '_'}; },
- 'container' => function () { return $this; },
- )));
- }
-
- /**
- * Gets the 'lazy_referenced' service.
- *
- * This service is shared.
- * This method always returns the same instance of the service.
- *
- * @return \stdClass A stdClass instance
- */
- protected function getLazyReferencedService()
- {
- return $this->services['lazy_referenced'] = new \stdClass();
- }
-}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php
index 6626db5567442..445744b70c1ec 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php
@@ -7,7 +7,6 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
-use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* ProjectServiceContainer.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml
index fee5a138ce1d7..545e31e79b3ca 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml
@@ -137,13 +137,6 @@
-
-
-
-
-
-
-
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_locator_argument.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_locator_argument.xml
deleted file mode 100644
index 93dbef712ee43..0000000000000
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_locator_argument.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- BazClass
- bar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml
index e7dcd28b6ab71..44df6bdf97a1f 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml
@@ -121,9 +121,6 @@ services:
arguments: [!closure_proxy ['@closure_proxy', getBaz]]
alias_for_foo: '@foo'
alias_for_alias: '@foo'
- service_locator:
- class: Bar
- arguments: [!service_locator { bar: '@bar', invalid: '@?invalid', container: '@service_container' }]
Psr\Container\ContainerInterface:
alias: service_container
public: false
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_locator_argument.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_locator_argument.yml
deleted file mode 100644
index ee72e51f79fd4..0000000000000
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_locator_argument.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-parameters:
- baz_class: BazClass
- foo: bar
-
-services:
- foo.baz:
- class: '%baz_class%'
- factory: ['%baz_class%', getInstance]
- configurator: ['%baz_class%', configureStatic1]
- lazy_context:
- class: LazyContext
- arguments: [!service_locator {foo_baz: '@foo.baz', container: '@service_container'} ]
- lazy_context_ignore_invalid_ref:
- class: LazyContext
- arguments: [!service_locator {foo_baz: '@foo.baz', invalid: '@?invalid'}]
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
index 7cf4026dd9950..0af879ef35c8f 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
@@ -13,7 +13,6 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
@@ -278,16 +277,6 @@ public function testParsesIteratorArgument()
$this->assertEquals(array(new IteratorArgument(array('foo', new Reference('foo.baz'), array('%foo%' => 'foo is %foo%', 'foobar' => '%foo%'), true, new Reference('service_container')))), $lazyDefinition->getArguments(), '->load() parses lazy arguments');
}
- public function testParsesServiceLocatorArgument()
- {
- $container = new ContainerBuilder();
- $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
- $loader->load('services_locator_argument.xml');
-
- $this->assertEquals(array(new ServiceLocatorArgument(array('foo_baz' => new Reference('foo.baz'), 'container' => new Reference('service_container')))), $container->getDefinition('lazy_context')->getArguments(), '->load() parses service-locator arguments');
- $this->assertEquals(array(new ServiceLocatorArgument(array('foo_baz' => new Reference('foo.baz'), 'invalid' => new Reference('invalid', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))), $container->getDefinition('lazy_context_ignore_invalid_ref')->getArguments(), '->load() parses service-locator arguments');
- }
-
public function testParsesTags()
{
$container = new ContainerBuilder();
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
index 3c69c50c8679c..43e1f5ec5c7fc 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
@@ -13,7 +13,6 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
@@ -356,16 +355,6 @@ public function testParsesIteratorArgument()
$this->assertEquals(array(new IteratorArgument(array('foo', new Reference('foo.baz'), array('%foo%' => 'foo is %foo%', 'foobar' => '%foo%'), true, new Reference('service_container')))), $lazyDefinition->getArguments(), '->load() parses lazy arguments');
}
- public function testParsesServiceLocatorArgument()
- {
- $container = new ContainerBuilder();
- $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
- $loader->load('services_locator_argument.yml');
-
- $this->assertEquals(array(new ServiceLocatorArgument(array('foo_baz' => new Reference('foo.baz'), 'container' => new Reference('service_container')))), $container->getDefinition('lazy_context')->getArguments(), '->load() parses service-locator arguments');
- $this->assertEquals(array(new ServiceLocatorArgument(array('foo_baz' => new Reference('foo.baz'), 'invalid' => new Reference('invalid', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))), $container->getDefinition('lazy_context_ignore_invalid_ref')->getArguments(), '->load() parses service-locator arguments');
- }
-
public function testAutowire()
{
$container = new ContainerBuilder();
diff --git a/src/Symfony/Component/DependencyInjection/TypedReference.php b/src/Symfony/Component/DependencyInjection/TypedReference.php
index 7285070ea925a..bb57bedb52521 100644
--- a/src/Symfony/Component/DependencyInjection/TypedReference.php
+++ b/src/Symfony/Component/DependencyInjection/TypedReference.php
@@ -15,8 +15,6 @@
* Represents a PHP type-hinted service reference.
*
* @author Nicolas Grekas
- *
- * @experimental in version 3.3
*/
class TypedReference extends Reference
{
diff --git a/src/Symfony/Component/Form/DependencyInjection/FormPass.php b/src/Symfony/Component/Form/DependencyInjection/FormPass.php
index 5a18a69c3e333..d905db51454ee 100644
--- a/src/Symfony/Component/Form/DependencyInjection/FormPass.php
+++ b/src/Symfony/Component/Form/DependencyInjection/FormPass.php
@@ -12,13 +12,14 @@
namespace Symfony\Component\Form\DependencyInjection;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
+use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\ServiceLocator;
/**
* Adds all services with the tags "form.type", "form.type_extension" and
@@ -60,19 +61,16 @@ private function processFormTypes(ContainerBuilder $container, Definition $defin
// Get service locator argument
$servicesMap = array();
$locator = $definition->getArgument(0);
- if ($locator instanceof ServiceLocatorArgument) {
- $servicesMap = $locator->getValues();
- }
// Builds an array with fully-qualified type class names as keys and service IDs as values
foreach ($container->findTaggedServiceIds($this->formTypeTag) as $serviceId => $tag) {
$serviceDefinition = $container->getDefinition($serviceId);
// Add form type service to the service locator
- $servicesMap[$serviceDefinition->getClass()] = new Reference($serviceId);
+ $servicesMap[$serviceDefinition->getClass()] = new ServiceClosureArgument(new Reference($serviceId));
}
- return new ServiceLocatorArgument($servicesMap);
+ return (new Definition(ServiceLocator::class, array($servicesMap)))->addTag('container.service_locator');
}
private function processFormTypeExtensions(ContainerBuilder $container)
diff --git a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php
index 799d4aff13772..9f454faa927e0 100644
--- a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php
+++ b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php
@@ -13,11 +13,12 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
+use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\Form\DependencyInjection\FormPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\Form\AbstractType;
/**
@@ -47,10 +48,10 @@ public function testAddTaggedTypes()
$extDefinition = $container->getDefinition('form.extension');
$this->assertEquals(
- new ServiceLocatorArgument(array(
- __CLASS__.'_Type1' => new Reference('my.type1'),
- __CLASS__.'_Type2' => new Reference('my.type2'),
- )),
+ (new Definition(ServiceLocator::class, array(array(
+ __CLASS__.'_Type1' => new ServiceClosureArgument(new Reference('my.type1')),
+ __CLASS__.'_Type2' => new ServiceClosureArgument(new Reference('my.type2')),
+ ))))->addTag('container.service_locator'),
$extDefinition->getArgument(0)
);
}
@@ -185,7 +186,7 @@ private function createExtensionDefinition()
{
$definition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension');
$definition->setArguments(array(
- new ServiceLocatorArgument(array()),
+ array(),
array(),
new IteratorArgument(array()),
));
diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php
index bf4e2a17f4df0..5d4381b8785b3 100644
--- a/src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php
+++ b/src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php
@@ -11,11 +11,13 @@
namespace Symfony\Component\HttpKernel\DependencyInjection;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
+use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
/**
@@ -62,10 +64,10 @@ public function process(ContainerBuilder $container)
}
foreach ($tags as $tag) {
- $renderers[$tag['alias']] = new Reference($id);
+ $renderers[$tag['alias']] = new ServiceClosureArgument(new Reference($id));
}
}
- $definition->replaceArgument(0, new ServiceLocatorArgument($renderers));
+ $definition->replaceArgument(0, (new Definition(ServiceLocator::class, array($renderers)))->addTag('container.service_locator'));
}
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php
index c33db826ef154..de12604f067e3 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php
@@ -12,8 +12,10 @@
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
use PHPUnit\Framework\TestCase;
-use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
+use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
+use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass;
use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
@@ -63,7 +65,7 @@ public function testValidContentRenderer()
$renderer
->expects($this->once())
->method('replaceArgument')
- ->with(0, $this->equalTo(new ServiceLocatorArgument(array('foo' => new Reference('my_content_renderer')))));
+ ->with(0, $this->equalTo((new Definition(ServiceLocator::class, array(array('foo' => new ServiceClosureArgument(new Reference('my_content_renderer'))))))->addTag('container.service_locator')));
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$definition->expects($this->atLeastOnce())