diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index fcfd9f91c6..6b08295a9f 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -95,6 +95,10 @@ UPGRADE FROM 2.x to 3.0 been removed in favor of `Definition::setFactory()`. Services defined using YAML or XML use the same syntax as configurators. + * Synchronized services are deprecated and the following methods have been + removed: `ContainerBuilder::synchronize()`, `Definition::isSynchronized()`, + and `Definition::setSynchronized()`. + ### EventDispatcher * The interface `Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface` diff --git a/autoload.php.dist b/autoload.php.dist index 7e15d79ad0..3b3297d924 100644 --- a/autoload.php.dist +++ b/autoload.php.dist @@ -44,11 +44,7 @@ class DeprecationErrorHandler $class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class']; $method = $trace[$i]['function']; - $type = - 0 === strpos($method, 'testLegacy') - || 0 === strpos($method, 'provideLegacy') - || strpos($class, '\Legacy') - ? 'legacy' : 'remaining'; + $type = 0 === strpos($method, 'testLegacy') || 0 === strpos($method, 'provideLegacy') || 0 === strpos($method, 'getLegacy') || strpos($class, '\Legacy') ? 'legacy' : 'remaining'; if ('legacy' === $type && 0 === (error_reporting() & E_USER_DEPRECATED)) { @++$deprecations[$type]['Silenced']['count']; diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 3bd7633cf6..ed8773b5b5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -215,10 +215,13 @@ class JsonDescriptor extends Descriptor 'public' => $definition->isPublic(), 'synthetic' => $definition->isSynthetic(), 'lazy' => $definition->isLazy(), - 'synchronized' => $definition->isSynchronized(), - 'abstract' => $definition->isAbstract(), - 'file' => $definition->getFile(), ); + if (method_exists($definition, 'isSynchronized')) { + $data['synchronized'] = $definition->isSynchronized(); + } + + $data['abstract'] = $definition->isAbstract(); + $data['file'] = $definition->getFile(); if ($definition->getFactoryClass()) { $data['factory_class'] = $definition->getFactoryClass(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php index f18c486f60..2c753caa45 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php @@ -183,8 +183,13 @@ class MarkdownDescriptor extends Descriptor ."\n".'- Public: '.($definition->isPublic() ? 'yes' : 'no') ."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no') ."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no') - ."\n".'- Synchronized: '.($definition->isSynchronized() ? 'yes' : 'no') - ."\n".'- Abstract: '.($definition->isAbstract() ? 'yes' : 'no'); + ; + + if (method_exists($definition, 'isSynchronized')) { + $output .= "\n".'- Synchronized: '.($definition->isSynchronized() ? 'yes' : 'no'); + } + + $output .= "\n".'- Abstract: '.($definition->isAbstract() ? 'yes' : 'no'); if ($definition->getFile()) { $output .= "\n".'- File: `'.$definition->getFile().'`'; diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index f6c2fa6237..5886f1238d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -265,7 +265,9 @@ class TextDescriptor extends Descriptor $description[] = sprintf('Public %s', $definition->isPublic() ? 'yes' : 'no'); $description[] = sprintf('Synthetic %s', $definition->isSynthetic() ? 'yes' : 'no'); $description[] = sprintf('Lazy %s', $definition->isLazy() ? 'yes' : 'no'); - $description[] = sprintf('Synchronized %s', $definition->isSynchronized() ? 'yes' : 'no'); + if (method_exists($definition, 'isSynchronized')) { + $description[] = sprintf('Synchronized %s', $definition->isSynchronized() ? 'yes' : 'no'); + } $description[] = sprintf('Abstract %s', $definition->isAbstract() ? 'yes' : 'no'); if ($definition->getFile()) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php index 57918ad6e7..c37a9009fc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php @@ -366,7 +366,9 @@ class XmlDescriptor extends Descriptor $serviceXML->setAttribute('public', $definition->isPublic() ? 'true' : 'false'); $serviceXML->setAttribute('synthetic', $definition->isSynthetic() ? 'true' : 'false'); $serviceXML->setAttribute('lazy', $definition->isLazy() ? 'true' : 'false'); - $serviceXML->setAttribute('synchronized', $definition->isSynchronized() ? 'true' : 'false'); + if (method_exists($definition, 'isSynchronized')) { + $serviceXML->setAttribute('synchronized', $definition->isSynchronized(false) ? 'true' : 'false'); + } $serviceXML->setAttribute('abstract', $definition->isAbstract() ? 'true' : 'false'); $serviceXML->setAttribute('file', $definition->getFile()); diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index b78e440974..427294319e 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +2.7.0 +----- + + * deprecated synchronized services + 2.6.0 ----- diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index dc1a73d111..d91e371983 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -412,7 +412,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface parent::set($id, $service, $scope); - if (isset($this->obsoleteDefinitions[$id]) && $this->obsoleteDefinitions[$id]->isSynchronized()) { + if (isset($this->obsoleteDefinitions[$id]) && $this->obsoleteDefinitions[$id]->isSynchronized(false)) { $this->synchronize($id); } } @@ -1121,9 +1121,15 @@ class ContainerBuilder extends Container implements TaggedContainerInterface * service by calling all methods referencing it. * * @param string $id A service id + * + * @deprecated since version 2.7, will be removed in 3.0. */ private function synchronize($id) { + if ('request' !== $id) { + trigger_error('The '.__METHOD__.' method is deprecated in version 2.7 and will be removed in version 3.0.', E_USER_DEPRECATED); + } + foreach ($this->definitions as $definitionId => $definition) { // only check initialized services if (!$this->initialized($definitionId)) { diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 446d13aa2b..eb5469cfae 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -661,9 +661,15 @@ class Definition * @return Definition The current instance * * @api + * + * @deprecated since version 2.7, will be removed in 3.0. */ - public function setSynchronized($boolean) + public function setSynchronized($boolean, $triggerDeprecationError = true) { + if ($triggerDeprecationError) { + trigger_error('The '.__METHOD__.' method is deprecated in version 2.7 and will be removed in version 3.0.', E_USER_DEPRECATED); + } + $this->synchronized = (bool) $boolean; return $this; @@ -675,9 +681,15 @@ class Definition * @return bool * * @api + * + * @deprecated since version 2.7, will be removed in 3.0. */ - public function isSynchronized() + public function isSynchronized($triggerDeprecationError = true) { + if ($triggerDeprecationError) { + trigger_error('The '.__METHOD__.' method is deprecated in version 2.7 and will be removed in version 3.0.', E_USER_DEPRECATED); + } + return $this->synchronized; } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index caa5641671..6fc57aeeb6 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -695,13 +695,19 @@ EOF; * @param Definition $definition A Definition instance * * @return string|null + * + * @deprecated since version 2.7, will be removed in 3.0. */ private function addServiceSynchronizer($id, Definition $definition) { - if (!$definition->isSynchronized()) { + if (!$definition->isSynchronized(false)) { return; } + if ('request' !== $id) { + trigger_error('Synchronized services were deprecated in version 2.7 and won\'t work anymore in 3.0.', E_USER_DEPRECATED); + } + $code = ''; foreach ($this->container->getDefinitions() as $definitionId => $definition) { foreach ($definition->getMethodCalls() as $call) { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php index 1d19b2c862..0a73100622 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php @@ -135,7 +135,7 @@ class XmlDumper extends Dumper if ($definition->isSynthetic()) { $service->setAttribute('synthetic', 'true'); } - if ($definition->isSynchronized()) { + if ($definition->isSynchronized(false)) { $service->setAttribute('synchronized', 'true'); } if ($definition->isLazy()) { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index a7ed2e8064..f2a3e855a4 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -103,7 +103,7 @@ class YamlDumper extends Dumper $code .= sprintf(" synthetic: true\n"); } - if ($definition->isSynchronized()) { + if ($definition->isSynchronized(false)) { $code .= sprintf(" synchronized: true\n"); } diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 514f4f396f..52328ddd54 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -145,13 +145,17 @@ class XmlFileLoader extends FileLoader $definition = new Definition(); } - foreach (array('class', 'scope', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'synchronized', 'lazy', 'abstract') as $key) { + foreach (array('class', 'scope', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'lazy', 'abstract') as $key) { if ($value = $service->getAttribute($key)) { $method = 'set'.str_replace('-', '', $key); $definition->$method(XmlUtils::phpize($value)); } } + if ($value = $service->getAttribute('synchronized')) { + $definition->setSynchronized(XmlUtils::phpize($value), 'request' !== $id); + } + if ($files = $this->getChildren($service, 'file')) { $definition->setFile($files[0]->nodeValue); } diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 85f6ee6962..54ad8be7c8 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -171,7 +171,7 @@ class YamlFileLoader extends FileLoader } if (isset($service['synchronized'])) { - $definition->setSynchronized($service['synchronized']); + $definition->setSynchronized($service['synchronized'], 'request' !== $id); } if (isset($service['lazy'])) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index e0ff297f9b..cd1a90056d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -683,8 +683,10 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $this->assertEquals($a, $container->get('a')); } - public function testSetOnSynchronizedService() + public function testLegacySetOnSynchronizedService() { + $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); + $container = new ContainerBuilder(); $container->register('baz', 'BazClass') ->setSynchronized(true) @@ -700,8 +702,10 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $this->assertSame($baz, $container->get('bar')->getBaz()); } - public function testSynchronizedServiceWithScopes() + public function testLegacySynchronizedServiceWithScopes() { + $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); + $container = new ContainerBuilder(); $container->addScope(new Scope('foo')); $container->register('baz', 'BazClass') diff --git a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php index 583d49f1e9..8588dd7e75 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php @@ -167,8 +167,10 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase * @covers Symfony\Component\DependencyInjection\Definition::setSynchronized * @covers Symfony\Component\DependencyInjection\Definition::isSynchronized */ - public function testSetIsSynchronized() + public function testLegacySetIsSynchronized() { + $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); + $def = new Definition('stdClass'); $this->assertFalse($def->isSynchronized(), '->isSynchronized() returns false by default'); $this->assertSame($def, $def->setSynchronized(true), '->setSynchronized() implements a fluent interface'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 882c5d8a12..01e5710fce 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -124,6 +124,15 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase } } + public function testLegacySynchronizedServices() + { + $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); + + $container = include self::$fixturesPath.'/containers/container20.php'; + $dumper = new PhpDumper($container); + $this->assertEquals(str_replace('%path%', str_replace('\\', '\\\\', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), file_get_contents(self::$fixturesPath.'/php/services20.php')), $dumper->dump(), '->dump() dumps services'); + } + public function testServicesWithAnonymousFactories() { $container = include self::$fixturesPath.'/containers/container19.php'; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container20.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container20.php new file mode 100644 index 0000000000..a40a0e8a6c --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container20.php @@ -0,0 +1,19 @@ +register('request', 'Request') + ->setSynchronized(true) +; +$container + ->register('depends_on_request', 'stdClass') + ->addMethodCall('setRequest', array(new Reference('request', ContainerInterface::NULL_ON_INVALID_REFERENCE, false))) +; + +return $container; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php index 49262e8632..a2a0f87214 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php @@ -77,11 +77,6 @@ $container $container ->register('request', 'Request') ->setSynthetic(true) - ->setSynchronized(true) -; -$container - ->register('depends_on_request', 'stdClass') - ->addMethodCall('setRequest', array(new Reference('request', ContainerInterface::NULL_ON_INVALID_REFERENCE, false))) ; $container ->register('configurator_service', 'ConfClass') diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot index e233d62594..78961c83b7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot @@ -13,7 +13,6 @@ digraph sc { node_inlined [label="inlined\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_baz [label="baz\nBaz\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_request [label="request\nRequest\n", shape=record, fillcolor="#eeeeee", style="filled"]; - node_depends_on_request [label="depends_on_request\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_configurator_service [label="configurator_service\nConfClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_configured_service [label="configured_service\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_decorated [label="decorated\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; @@ -38,6 +37,5 @@ digraph sc { node_foo_with_inline -> node_inlined [label="setBar()" style="dashed"]; node_inlined -> node_baz [label="setBaz()" style="dashed"]; node_baz -> node_foo_with_inline [label="setFoo()" style="dashed"]; - node_depends_on_request -> node_request [label="setRequest()" style="dashed"]; node_configurator_service -> node_baz [label="setFoo()" style="dashed"]; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services20.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services20.php new file mode 100644 index 0000000000..f5f1fa4052 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services20.php @@ -0,0 +1,73 @@ +methodMap = array( + 'depends_on_request' => 'getDependsOnRequestService', + 'request' => 'getRequestService', + ); + } + + /** + * Gets the 'depends_on_request' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return \stdClass A stdClass instance. + */ + protected function getDependsOnRequestService() + { + $this->services['depends_on_request'] = $instance = new \stdClass(); + + $instance->setRequest($this->get('request', ContainerInterface::NULL_ON_INVALID_REFERENCE)); + + return $instance; + } + + /** + * Gets the 'request' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return \Request A Request instance. + */ + protected function getRequestService() + { + return $this->services['request'] = new \Request(); + } + + /** + * Updates the 'request' service. + */ + protected function synchronizeRequestService() + { + if ($this->initialized('depends_on_request')) { + $this->get('depends_on_request')->setRequest($this->get('request', ContainerInterface::NULL_ON_INVALID_REFERENCE)); + } + } +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php index 33cbe2f8be..3a079b7915 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php @@ -33,7 +33,6 @@ class ProjectServiceContainer extends Container 'decorated' => 'getDecoratedService', 'decorator_service' => 'getDecoratorServiceService', 'decorator_service_with_name' => 'getDecoratorServiceWithNameService', - 'depends_on_request' => 'getDependsOnRequestService', 'factory_service' => 'getFactoryServiceService', 'foo' => 'getFooService', 'foo.baz' => 'getFoo_BazService', @@ -144,23 +143,6 @@ class ProjectServiceContainer extends Container return $this->services['decorator_service_with_name'] = new \stdClass(); } - /** - * Gets the 'depends_on_request' service. - * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance. - */ - protected function getDependsOnRequestService() - { - $this->services['depends_on_request'] = $instance = new \stdClass(); - - $instance->setRequest($this->get('request', ContainerInterface::NULL_ON_INVALID_REFERENCE)); - - return $instance; - } - /** * Gets the 'factory_service' service. * @@ -314,16 +296,6 @@ class ProjectServiceContainer extends Container return $this->services['service_from_static_method'] = \Bar\FooClass::getInstance(); } - /** - * Updates the 'request' service. - */ - protected function synchronizeRequestService() - { - if ($this->initialized('depends_on_request')) { - $this->get('depends_on_request')->setRequest($this->get('request', ContainerInterface::NULL_ON_INVALID_REFERENCE)); - } - } - /** * 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 71a47dc135..7c1a49d46f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -40,7 +40,6 @@ class ProjectServiceContainer extends Container 'configured_service' => 'getConfiguredServiceService', 'decorator_service' => 'getDecoratorServiceService', 'decorator_service_with_name' => 'getDecoratorServiceWithNameService', - 'depends_on_request' => 'getDependsOnRequestService', 'factory_service' => 'getFactoryServiceService', 'foo' => 'getFooService', 'foo.baz' => 'getFoo_BazService', @@ -148,23 +147,6 @@ class ProjectServiceContainer extends Container return $this->services['decorator_service_with_name'] = new \stdClass(); } - /** - * Gets the 'depends_on_request' service. - * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return \stdClass A stdClass instance. - */ - protected function getDependsOnRequestService() - { - $this->services['depends_on_request'] = $instance = new \stdClass(); - - $instance->setRequest($this->get('request', ContainerInterface::NULL_ON_INVALID_REFERENCE)); - - return $instance; - } - /** * Gets the 'factory_service' service. * @@ -318,16 +300,6 @@ class ProjectServiceContainer extends Container return $this->services['service_from_static_method'] = \Bar\FooClass::getInstance(); } - /** - * Updates the 'request' service. - */ - protected function synchronizeRequestService() - { - if ($this->initialized('depends_on_request')) { - $this->get('depends_on_request')->setRequest($this->get('request', ContainerInterface::NULL_ON_INVALID_REFERENCE)); - } - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services20.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services20.xml new file mode 100644 index 0000000000..5d799fc944 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services20.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml index 7234a82cdc..bd4d982328 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml @@ -74,12 +74,7 @@ - - - - - - + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services20.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services20.yml new file mode 100644 index 0000000000..847f656886 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services20.yml @@ -0,0 +1,9 @@ +services: + request: + class: Request + synthetic: true + synchronized: true + depends_on_request: + class: stdClass + calls: + - [setRequest, ['@?request']] diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml index 0b8da43968..9270109861 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml @@ -64,12 +64,6 @@ services: request: class: Request synthetic: true - synchronized: true - depends_on_request: - class: stdClass - calls: - - [setRequest, ['@?request']] - configurator_service: class: ConfClass public: false diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index 1d2bea0dce..043440212d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -219,7 +219,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array('BazClass', 'getInstance'), $services['new_factory3']->getFactory(), '->load() parses the factory tag'); $this->assertTrue($services['request']->isSynthetic(), '->load() parses the synthetic flag'); - $this->assertTrue($services['request']->isSynchronized(), '->load() parses the synchronized flag'); + $this->assertTrue($services['request']->isSynchronized(false), '->load() parses the synchronized flag'); $this->assertTrue($services['request']->isLazy(), '->load() parses the lazy flag'); $aliases = $container->getAliases(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 3de0843dfb..9d35ee453f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -146,7 +146,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array('BazClass', 'getInstance'), $services['new_factory3']->getFactory(), '->load() parses the factory tag'); $this->assertTrue($services['request']->isSynthetic(), '->load() parses the synthetic flag'); - $this->assertTrue($services['request']->isSynchronized(), '->load() parses the synchronized flag'); + $this->assertTrue($services['request']->isSynchronized(false), '->load() parses the synchronized flag'); $this->assertTrue($services['request']->isLazy(), '->load() parses the lazy flag'); $aliases = $container->getAliases();