diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php index 3d4fc46e1fff4..229cacf8255a9 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -333,6 +333,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD $memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && $cacheDriver['port'] === 0) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%'; $cacheDef = new Definition($memcacheClass); $memcacheInstance = new Definition($memcacheInstanceClass); + $memcacheInstance->setPrivate(true); $memcacheInstance->addMethodCall('connect', array( $memcacheHost, $memcachePort, )); @@ -346,6 +347,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD $memcachedPort = !empty($cacheDriver['port']) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcached_port').'%'; $cacheDef = new Definition($memcachedClass); $memcachedInstance = new Definition($memcachedInstanceClass); + $memcachedInstance->setPrivate(true); $memcachedInstance->addMethodCall('addServer', array( $memcachedHost, $memcachedPort, )); @@ -359,6 +361,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD $redisPort = !empty($cacheDriver['port']) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.redis_port').'%'; $cacheDef = new Definition($redisClass); $redisInstance = new Definition($redisInstanceClass); + $redisInstance->setPrivate(true); $redisInstance->addMethodCall('connect', array( $redisHost, $redisPort, )); diff --git a/src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php b/src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php index 835d823664021..d7c0ee7287468 100644 --- a/src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php +++ b/src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php @@ -35,6 +35,9 @@ public function load(array $configs, ContainerBuilder $container) $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.xml'); + $container->getDefinition('debug.dump_listener')->setPrivate(true); + $container->getDefinition('var_dumper.cli_dumper')->setPrivate(true); + $container->getDefinition('var_dumper.cloner') ->addMethodCall('setMaxItems', array($config['max_items'])) ->addMethodCall('setMinDepth', array($config['min_depth'])) diff --git a/src/Symfony/Bundle/DebugBundle/Resources/config/services.xml b/src/Symfony/Bundle/DebugBundle/Resources/config/services.xml index 79460a160259a..7e276dafab5d2 100644 --- a/src/Symfony/Bundle/DebugBundle/Resources/config/services.xml +++ b/src/Symfony/Bundle/DebugBundle/Resources/config/services.xml @@ -22,14 +22,14 @@ null - + - + null %kernel.charset% 0 diff --git a/src/Symfony/Bundle/DebugBundle/composer.json b/src/Symfony/Bundle/DebugBundle/composer.json index 5ad163e3031a3..7b59b82c765f6 100644 --- a/src/Symfony/Bundle/DebugBundle/composer.json +++ b/src/Symfony/Bundle/DebugBundle/composer.json @@ -24,9 +24,12 @@ }, "require-dev": { "symfony/config": "~3.3|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", "symfony/web-profiler-bundle": "~2.8|~3.0|~4.0" }, + "conflict": { + "symfony/dependency-injection": "<3.4" + }, "suggest": { "symfony/config": "For service container configuration", "symfony/dependency-injection": "For using as a service from the container" diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 9b3a071168a51..0ead938a1bf10 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -115,6 +115,15 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('web.xml'); $loader->load('services.xml'); + $container->getDefinition('kernel.class_cache.cache_warmer')->setPrivate(true); + $container->getDefinition('uri_signer')->setPrivate(true); + $container->getDefinition('config_cache_factory')->setPrivate(true); + $container->getDefinition('response_listener')->setPrivate(true); + $container->getDefinition('file_locator')->setPrivate(true); + $container->getDefinition('streamed_response_listener')->setPrivate(true); + $container->getDefinition('locale_listener')->setPrivate(true); + $container->getDefinition('validate_request_listener')->setPrivate(true); + // forward compatibility with Symfony 4.0 where the ContainerAwareEventDispatcher class is removed if (!class_exists(ContainerAwareEventDispatcher::class)) { $definition = $container->getDefinition('event_dispatcher'); @@ -131,6 +140,12 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('fragment_renderer.xml'); + $container->getDefinition('fragment.handler')->setPrivate(true); + $container->getDefinition('fragment.renderer.inline')->setPrivate(true); + $container->getDefinition('fragment.renderer.hinclude')->setPrivate(true); + $container->getDefinition('fragment.renderer.esi')->setPrivate(true); + $container->getDefinition('fragment.renderer.ssi')->setPrivate(true); + if (class_exists(Application::class)) { $loader->load('console.xml'); @@ -145,9 +160,20 @@ public function load(array $configs, ContainerBuilder $container) // Property access is used by both the Form and the Validator component $loader->load('property_access.xml'); + $container->getDefinition('property_accessor')->setPrivate(true); + // Load Cache configuration first as it is used by other components $loader->load('cache.xml'); + $container->getDefinition('cache.adapter.system')->setPrivate(true); + $container->getDefinition('cache.adapter.apcu')->setPrivate(true); + $container->getDefinition('cache.adapter.doctrine')->setPrivate(true); + $container->getDefinition('cache.adapter.filesystem')->setPrivate(true); + $container->getDefinition('cache.adapter.psr6')->setPrivate(true); + $container->getDefinition('cache.adapter.redis')->setPrivate(true); + $container->getDefinition('cache.adapter.memcached')->setPrivate(true); + $container->getDefinition('cache.default_clearer')->setPrivate(true); + $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); @@ -202,6 +228,10 @@ public function load(array $configs, ContainerBuilder $container) if (!empty($config['test'])) { $loader->load('test.xml'); + + $container->getDefinition('test.client.history')->setPrivate(true); + $container->getDefinition('test.client.cookiejar')->setPrivate(true); + $container->getDefinition('test.session.listener')->setPrivate(true); } if ($this->isConfigEnabled($container, $config['session'])) { @@ -389,6 +419,19 @@ public function getConfiguration(array $config, ContainerBuilder $container) private function registerFormConfiguration($config, ContainerBuilder $container, XmlFileLoader $loader) { $loader->load('form.xml'); + + $container->getDefinition('form.resolved_type_factory')->setPrivate(true); + $container->getDefinition('form.registry')->setPrivate(true); + $container->getDefinition('form.type_guesser.validator')->setPrivate(true); + $container->getDefinition('form.type.form')->setPrivate(true); + $container->getDefinition('form.type.choice')->setPrivate(true); + $container->getDefinition('form.type_extension.form.http_foundation')->setPrivate(true); + $container->getDefinition('form.type_extension.form.validator')->setPrivate(true); + $container->getDefinition('form.type_extension.repeated.validator')->setPrivate(true); + $container->getDefinition('form.type_extension.submit.validator')->setPrivate(true); + $container->getDefinition('form.type_extension.upload.validator')->setPrivate(true); + $container->getDefinition('deprecated.form.registry')->setPrivate(true); + if (null === $config['form']['csrf_protection']['enabled']) { $config['form']['csrf_protection']['enabled'] = $config['csrf_protection']['enabled']; } @@ -396,6 +439,9 @@ private function registerFormConfiguration($config, ContainerBuilder $container, if ($this->isConfigEnabled($container, $config['form']['csrf_protection'])) { $loader->load('form_csrf.xml'); + $container->getDefinition('form.type_extension.csrf')->setPrivate(true); + $container->getDefinition('deprecated.form.registry.csrf')->setPrivate(true); + $container->setParameter('form.type_extension.csrf.enabled', true); $container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']); } else { @@ -419,6 +465,9 @@ private function registerEsiConfiguration(array $config, ContainerBuilder $conta } $loader->load('esi.xml'); + + $container->getDefinition('esi')->setPrivate(true); + $container->getDefinition('esi_listener')->setPrivate(true); } /** @@ -437,6 +486,9 @@ private function registerSsiConfiguration(array $config, ContainerBuilder $conta } $loader->load('ssi.xml'); + + $container->getDefinition('ssi')->setPrivate(true); + $container->getDefinition('ssi_listener')->setPrivate(true); } /** @@ -480,8 +532,16 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $ $loader->load('collectors.xml'); $loader->load('cache_debug.xml'); + $container->getDefinition('data_collector.request')->setPrivate(true); + $container->getDefinition('data_collector.router')->setPrivate(true); + $container->getDefinition('profiler_listener')->setPrivate(true); + if ($this->formConfigEnabled) { $loader->load('form_debug.xml'); + + $container->getDefinition('form.resolved_type_factory')->setPrivate(true); + $container->getDefinition('data_collector.form.extractor')->setPrivate(true); + $container->getDefinition('data_collector.form')->setPrivate(true); } if ($this->validatorConfigEnabled) { @@ -490,6 +550,9 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $ if ($this->translationConfigEnabled) { $loader->load('translation_debug.xml'); + + $container->getDefinition('data_collector.translation')->setPrivate(true); + $container->getDefinition('translator.data_collector')->setDecoratedService('translator'); } @@ -506,7 +569,7 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $ if ($this->isConfigEnabled($container, $config['matcher'])) { if (isset($config['matcher']['service'])) { - $container->setAlias('profiler.request_matcher', $config['matcher']['service']); + $container->setAlias('profiler.request_matcher', $config['matcher']['service'])->setPrivate(true); } elseif (isset($config['matcher']['ip']) || isset($config['matcher']['path']) || isset($config['matcher']['ips'])) { $definition = $container->register('profiler.request_matcher', 'Symfony\\Component\\HttpFoundation\\RequestMatcher'); $definition->setPublic(false); @@ -553,6 +616,10 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ $loader->load('workflow.xml'); + $container->getDefinition('workflow.marking_store.multiple_state')->setPrivate(true); + $container->getDefinition('workflow.marking_store.single_state')->setPrivate(true); + $container->getDefinition('workflow.registry')->setPrivate(true); + $registryDefinition = $container->getDefinition('workflow.registry'); foreach ($config['workflows'] as $name => $workflow) { @@ -626,6 +693,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ // Enable the AuditTrail if ($workflow['audit_trail']['enabled']) { $listener = new Definition(Workflow\EventListener\AuditTrailListener::class); + $listener->setPrivate(true); $listener->addTag('monolog.logger', array('channel' => 'workflow')); $listener->addTag('kernel.event_listener', array('event' => sprintf('workflow.%s.leave', $name), 'method' => 'onLeave')); $listener->addTag('kernel.event_listener', array('event' => sprintf('workflow.%s.transition', $name), 'method' => 'onTransition')); @@ -636,6 +704,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ // Add Guard Listener $guard = new Definition(Workflow\EventListener\GuardListener::class); + $guard->setPrivate(true); $configuration = array(); foreach ($workflow['transitions'] as $transitionName => $config) { if (!isset($config['guard'])) { @@ -681,8 +750,10 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con { $loader->load('debug_prod.xml'); + $container->getDefinition('debug.debug_handlers_listener')->setPrivate(true); + if (class_exists(Stopwatch::class)) { - $container->register('debug.stopwatch', Stopwatch::class)->addArgument(true); + $container->register('debug.stopwatch', Stopwatch::class)->addArgument(true)->setPrivate(true); $container->setAlias(Stopwatch::class, new Alias('debug.stopwatch', false)); } @@ -694,6 +765,9 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con if ($debug && class_exists(Stopwatch::class)) { $loader->load('debug.xml'); + $container->getDefinition('debug.event_dispatcher')->setPrivate(true); + $container->getDefinition('debug.controller_resolver')->setPrivate(true); + $container->getDefinition('debug.argument_resolver')->setPrivate(true); } $definition = $container->findDefinition('debug.debug_handlers_listener'); @@ -734,6 +808,8 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co $loader->load('routing.xml'); + $container->getDefinition('router_listener')->setPrivate(true); + $container->setParameter('router.resource', $config['resource']); $container->setParameter('router.cache_class_prefix', $container->getParameter('kernel.container_class')); $router = $container->findDefinition('router.default'); @@ -792,8 +868,14 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c { $loader->load('session.xml'); + $container->getDefinition('session.storage.native')->setPrivate(true); + $container->getDefinition('session.storage.php_bridge')->setPrivate(true); + $container->getDefinition('session_listener')->setPrivate(true); + $container->getDefinition('session.save_listener')->setPrivate(true); + $container->getAlias('session.storage.filesystem')->setPrivate(true); + // session storage - $container->setAlias('session.storage', $config['storage_id']); + $container->setAlias('session.storage', $config['storage_id'])->setPrivate(true); $options = array(); foreach (array('name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor', 'use_strict_mode') as $key) { if (isset($config[$key])) { @@ -816,7 +898,7 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c $handlerId = 'session.handler.write_check'; } - $container->setAlias('session.handler', $handlerId); + $container->setAlias('session.handler', $handlerId)->setPrivate(true); } $container->setParameter('session.save_path', $config['save_path']); @@ -853,6 +935,9 @@ private function registerRequestConfiguration(array $config, ContainerBuilder $c { if ($config['formats']) { $loader->load('request.xml'); + + $container->getDefinition('request.add_request_formats_listener')->setPrivate(true); + $container ->getDefinition('request.add_request_formats_listener') ->replaceArgument(0, $config['formats']) @@ -871,6 +956,9 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder { $loader->load('templating.xml'); + $container->getDefinition('templating.name_parser')->setPrivate(true); + $container->getDefinition('templating.filename_parser')->setPrivate(true); + $container->setParameter('fragment.renderer.hinclude.global_template', $config['hinclude_default_template']); if ($container->getParameter('kernel.debug')) { @@ -889,10 +977,10 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder // Use a delegation unless only a single loader was registered if (1 === count($loaders)) { - $container->setAlias('templating.loader', (string) reset($loaders)); + $container->setAlias('templating.loader', (string) reset($loaders))->setPrivate(true); } else { $container->getDefinition('templating.loader.chain')->addArgument($loaders); - $container->setAlias('templating.loader', 'templating.loader.chain'); + $container->setAlias('templating.loader', 'templating.loader.chain')->setPrivate(true); } } @@ -937,13 +1025,25 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder if (in_array('php', $config['engines'], true)) { $loader->load('templating_php.xml'); + $container->getDefinition('templating.helper.slots')->setPrivate(true); + $container->getDefinition('templating.helper.request')->setPrivate(true); + $container->getDefinition('templating.helper.session')->setPrivate(true); + $container->getDefinition('templating.helper.router')->setPrivate(true); + $container->getDefinition('templating.helper.assets')->setPrivate(true); + $container->getDefinition('templating.helper.actions')->setPrivate(true); + $container->getDefinition('templating.helper.code')->setPrivate(true); + $container->getDefinition('templating.helper.translator')->setPrivate(true); + $container->getDefinition('templating.helper.form')->setPrivate(true); + $container->getDefinition('templating.helper.stopwatch')->setPrivate(true); + $container->getDefinition('templating.globals')->setPrivate(true); + $container->setParameter('templating.helper.form.resources', $config['form']['resources']); if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) { $loader->load('templating_debug.xml'); $container->setDefinition('templating.engine.php', $container->findDefinition('debug.templating.engine.php')); - $container->setAlias('debug.templating.engine.php', 'templating.engine.php'); + $container->setAlias('debug.templating.engine.php', 'templating.engine.php')->setPrivate(true); } if (\PHP_VERSION_ID < 70000) { @@ -977,6 +1077,12 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co { $loader->load('assets.xml'); + $container->getDefinition('assets.packages')->setPrivate(true); + $container->getDefinition('assets.context')->setPrivate(true); + $container->getDefinition('assets.path_package')->setPrivate(true); + $container->getDefinition('assets.url_package')->setPrivate(true); + $container->getDefinition('assets.static_version_strategy')->setPrivate(true); + $defaultVersion = null; if ($config['version_strategy']) { @@ -1073,6 +1179,35 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder $loader->load('translation.xml'); + $container->getDefinition('translator.default')->setPrivate(true); + $container->getDefinition('translation.loader.php')->setPrivate(true); + $container->getDefinition('translation.loader.yml')->setPrivate(true); + $container->getDefinition('translation.loader.xliff')->setPrivate(true); + $container->getDefinition('translation.loader.po')->setPrivate(true); + $container->getDefinition('translation.loader.mo')->setPrivate(true); + $container->getDefinition('translation.loader.qt')->setPrivate(true); + $container->getDefinition('translation.loader.csv')->setPrivate(true); + $container->getDefinition('translation.loader.res')->setPrivate(true); + $container->getDefinition('translation.loader.dat')->setPrivate(true); + $container->getDefinition('translation.loader.ini')->setPrivate(true); + $container->getDefinition('translation.loader.json')->setPrivate(true); + $container->getDefinition('translation.dumper.php')->setPrivate(true); + $container->getDefinition('translation.dumper.xliff')->setPrivate(true); + $container->getDefinition('translation.dumper.po')->setPrivate(true); + $container->getDefinition('translation.dumper.mo')->setPrivate(true); + $container->getDefinition('translation.dumper.yml')->setPrivate(true); + $container->getDefinition('translation.dumper.qt')->setPrivate(true); + $container->getDefinition('translation.dumper.csv')->setPrivate(true); + $container->getDefinition('translation.dumper.ini')->setPrivate(true); + $container->getDefinition('translation.dumper.json')->setPrivate(true); + $container->getDefinition('translation.dumper.res')->setPrivate(true); + $container->getDefinition('translation.extractor.php')->setPrivate(true); + $container->getDefinition('translator_listener')->setPrivate(true); + $container->getDefinition('translation.loader')->setPrivate(true); + $container->getDefinition('translation.reader')->setPrivate(true); + $container->getDefinition('translation.extractor')->setPrivate(true); + $container->getDefinition('translation.writer')->setPrivate(true); + // Use the "real" translator instead of the identity default $container->setAlias('translator', 'translator.default'); $container->setAlias('translator.formatter', new Alias($config['formatter'], false)); @@ -1169,6 +1304,10 @@ private function registerValidationConfiguration(array $config, ContainerBuilder $loader->load('validator.xml'); + $container->getDefinition('validator.builder')->setPrivate(true); + $container->getDefinition('validator.expression')->setPrivate(true); + $container->getDefinition('validator.email')->setPrivate(true); + $validatorBuilder = $container->getDefinition('validator.builder'); $container->setParameter('validator.translation_domain', $config['translation_domain']); @@ -1282,6 +1421,8 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde $loader->load('annotations.xml'); + $container->getAlias('annotation_reader')->setPrivate(true); + if ('none' !== $config['cache']) { if (!class_exists('Doctrine\Common\Cache\CacheProvider')) { throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.'); @@ -1408,6 +1549,9 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder } $loader->load('serializer.xml'); + + $container->getDefinition('serializer.mapping.cache.symfony')->setPrivate(true); + $chainLoader = $container->getDefinition('serializer.mapping.chain_loader'); $serializerLoaders = array(); @@ -1498,8 +1642,11 @@ private function registerPropertyInfoConfiguration(array $config, ContainerBuild { $loader->load('property_info.xml'); + $container->getDefinition('property_info')->setPrivate(true); + if (interface_exists('phpDocumentor\Reflection\DocBlockFactoryInterface')) { $definition = $container->register('property_info.php_doc_extractor', 'Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor'); + $definition->setPrivate(true); $definition->addTag('property_info.description_extractor', array('priority' => -1000)); $definition->addTag('property_info.type_extractor', array('priority' => -1001)); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml index 15bf002954199..6b290d7763867 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml @@ -49,7 +49,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.xml index e714e2834c5fc..9584afdb134ed 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.xml @@ -7,7 +7,7 @@ - + @@ -17,23 +17,23 @@ - + - + - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.xml index e0d5788bc4879..cbed70e4e11a1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.xml @@ -27,7 +27,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -71,14 +71,14 @@ - + 0 - + @@ -89,7 +89,7 @@ - + @@ -100,7 +100,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml index 8cd0c3ced0d8b..a1b73097e0bd7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml @@ -12,7 +12,7 @@ - + @@ -47,7 +47,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml index aa988dc5b93cf..9aa1367f585e1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml @@ -7,20 +7,20 @@ - + - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml index fc4efe4e02253..28a8a8a2c04b1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml @@ -11,7 +11,7 @@ - + null diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml index 8925acb1ac8f0..cd9fa061dd240 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml @@ -7,9 +7,9 @@ - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml index 642d8d4ee7bfc..211bccb688b49 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml @@ -8,11 +8,11 @@ - + - + - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_listener.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_listener.xml index a9628ad5609e5..49fbbbaf388cb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_listener.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_listener.xml @@ -7,7 +7,7 @@ - + %fragment.path% diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml index a24d2880ea823..3f518522e153c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml @@ -12,27 +12,27 @@ - + %kernel.debug% - + %fragment.path% - + %fragment.renderer.hinclude.global_template% %fragment.path% - + @@ -40,7 +40,7 @@ %fragment.path% - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml index c409e981de7bb..635dc8d2b3ed0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml @@ -17,7 +17,7 @@ %profiler.storage.dsn% - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_access.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_access.xml index 15e684b62ae2d..91924e5972d8e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_access.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_access.xml @@ -7,7 +7,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_info.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_info.xml index 8e0498e4f68b3..a893127276564 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_info.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_info.xml @@ -7,7 +7,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml index b9e9e9c7e058b..9cb049c01735f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml @@ -7,7 +7,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml index 22bd38f8b80d6..6856512e20349 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml @@ -102,7 +102,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml index d350091a01820..924ebf18d8b0f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml @@ -60,7 +60,7 @@ - + %serializer.mapping.cache.file% diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml index cecbdf8d85f2a..9ff2c259ee43b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml @@ -27,7 +27,7 @@ - + Symfony\Component\HttpFoundation\ParameterBag Symfony\Component\HttpFoundation\HeaderBag @@ -49,7 +49,7 @@ - + %kernel.root_dir%/Resources @@ -58,11 +58,11 @@ - + %kernel.secret% - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml index 2a930075bbf54..0cb86362a231e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml @@ -26,13 +26,13 @@ %session.metadata.update_threshold% - + %session.storage.options% - + @@ -53,7 +53,7 @@ - + @@ -65,11 +65,11 @@ - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/ssi.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/ssi.xml index 4df799fcf5fe3..8a3c0cb593bff 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/ssi.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/ssi.xml @@ -7,9 +7,9 @@ - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml index 1de55085c84f5..68b0eeefd7ccf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml @@ -12,11 +12,11 @@ - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml index 5eb7233592f65..5d4aa8625eefd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml @@ -20,53 +20,53 @@ - + - + - + - + - + - + - + %kernel.root_dir% %kernel.charset% - + - + - + @@ -81,7 +81,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/test.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/test.xml index 2b75d4c5b7016..ff109c4cd2420 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/test.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/test.xml @@ -18,11 +18,11 @@ - + - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml index d8c8f1e030111..b1f478ac90bac 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml @@ -7,7 +7,7 @@ - + %kernel.default_locale% @@ -32,67 +32,67 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -101,38 +101,38 @@ - + - + - + - + - + - + - + The "%service_id%" service is deprecated since Symfony 3.4 and will be removed in 4.0. Use "translation.reader" instead. - + - + - + @@ -140,7 +140,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation_debug.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation_debug.xml index ba30db65dcb80..945f8653a524a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation_debug.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation_debug.xml @@ -13,7 +13,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml index aa472d380cb33..66e7c7c23517e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml @@ -17,7 +17,7 @@ - + @@ -64,11 +64,11 @@ - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml index 1eed0e92f6c21..0622c4196c104 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml @@ -51,23 +51,23 @@ - + %kernel.charset% - + - + %kernel.default_locale% - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/workflow.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/workflow.xml index 0a033d692afdc..d881f699f75ec 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/workflow.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/workflow.xml @@ -20,10 +20,10 @@ - - + + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php index a9a5959848e67..9aa0c019d58af 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php @@ -58,10 +58,10 @@ public function testClearPoolWithCustomClearer() public function testCallClearer() { $tester = $this->createCommandTester(); - $tester->execute(array('pools' => array('cache.default_clearer')), array('decorated' => false)); + $tester->execute(array('pools' => array('cache.app_clearer')), array('decorated' => false)); $this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success'); - $this->assertContains('Calling cache clearer: cache.default_clearer', $tester->getDisplay()); + $this->assertContains('Calling cache clearer: cache.app_clearer', $tester->getDisplay()); $this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay()); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/PropertyInfoTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/PropertyInfoTest.php index c02a6b84e519c..f98072ce7b39c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/PropertyInfoTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/PropertyInfoTest.php @@ -20,7 +20,7 @@ public function testPhpDocPriority() static::bootKernel(array('test_case' => 'Serializer')); $container = static::$kernel->getContainer(); - $this->assertEquals(array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_INT))), $container->get('property_info')->getTypes('Symfony\Bundle\FrameworkBundle\Tests\Functional\Dummy', 'codes')); + $this->assertEquals(array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_INT))), $container->get('test.property_info')->getTypes('Symfony\Bundle\FrameworkBundle\Tests\Functional\Dummy', 'codes')); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/config.yml index cac135c315d00..fe3de69299946 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/config.yml @@ -1,6 +1,9 @@ imports: - { resource: ../config/default.yml } +services: + test.property_info: '@property_info' + framework: serializer: { enabled: true } property_info: { enabled: true } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 73a1cef128dd8..95e382b7b4226 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -73,8 +73,19 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('collectors.xml'); $loader->load('guard.xml'); + $container->getDefinition('security.authentication.guard_handler')->setPrivate(true); + $container->getDefinition('security.firewall')->setPrivate(true); + $container->getDefinition('security.firewall.context')->setPrivate(true); + $container->getDefinition('security.validator.user_password')->setPrivate(true); + $container->getDefinition('security.rememberme.response_listener')->setPrivate(true); + $container->getDefinition('templating.helper.logout_url')->setPrivate(true); + $container->getDefinition('templating.helper.security')->setPrivate(true); + $container->getAlias('security.encoder_factory')->setPrivate(true); + if ($container->hasParameter('kernel.debug') && $container->getParameter('kernel.debug')) { $loader->load('security_debug.xml'); + + $container->getAlias('security.firewall')->setPrivate(true); } if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { @@ -88,7 +99,7 @@ public function load(array $configs, ContainerBuilder $container) $container->setParameter('security.authentication.session_strategy.strategy', $config['session_fixation_strategy']); if (isset($config['access_decision_manager']['service'])) { - $container->setAlias('security.access.decision_manager', $config['access_decision_manager']['service']); + $container->setAlias('security.access.decision_manager', $config['access_decision_manager']['service'])->setPrivate(true); } else { $container ->getDefinition('security.access.decision_manager') @@ -151,13 +162,13 @@ private function aclLoad($config, ContainerBuilder $container) $loader->load('security_acl.xml'); if (isset($config['cache']['id'])) { - $container->setAlias('security.acl.cache', $config['cache']['id']); + $container->setAlias('security.acl.cache', $config['cache']['id'])->setPrivate(true); } $container->getDefinition('security.acl.voter.basic_permissions')->addArgument($config['voter']['allow_if_object_identity_unavailable']); // custom ACL provider if (isset($config['provider'])) { - $container->setAlias('security.acl.provider', $config['provider']); + $container->setAlias('security.acl.provider', $config['provider'])->setPrivate(true); return; } @@ -169,6 +180,10 @@ private function configureDbalAclProvider(array $config, ContainerBuilder $conta { $loader->load('security_acl_dbal.xml'); + $container->getDefinition('security.acl.dbal.schema')->setPrivate(true); + $container->getAlias('security.acl.dbal.connection')->setPrivate(true); + $container->getAlias('security.acl.provider')->setPrivate(true); + if (null !== $config['connection']) { $container->setAlias('security.acl.dbal.connection', sprintf('doctrine.dbal.%s_connection', $config['connection'])); } diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/guard.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/guard.xml index 77a09f24f8a95..ce6021823ba74 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/guard.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/guard.xml @@ -9,7 +9,6 @@ diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml index 9b31ae84439d7..79a4866d8cbe4 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml @@ -51,7 +51,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -118,7 +118,7 @@ - + @@ -169,7 +169,7 @@ - + diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_acl_dbal.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_acl_dbal.xml index 1399be3c12bde..c1ed332654fe0 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_acl_dbal.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_acl_dbal.xml @@ -7,7 +7,7 @@ - + @@ -22,7 +22,7 @@ - + %security.acl.dbal.class_table_name% %security.acl.dbal.entry_table_name% @@ -36,7 +36,7 @@ - + diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_debug.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_debug.xml index 6087f9ee5b19e..d3b7b936ea69a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_debug.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_debug.xml @@ -18,6 +18,6 @@ - + diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_rememberme.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_rememberme.xml index 1f0e288687606..c05cdcaa2d290 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_rememberme.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_rememberme.xml @@ -45,7 +45,7 @@ public="false" abstract="true" /> - + diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml index b0676e2fc15b1..6f2ec1cbf977e 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml @@ -7,12 +7,12 @@ - + - + diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php index 5ecbf47078afe..803109ec2097c 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php @@ -67,7 +67,7 @@ public function testSetAclUser() $permissionMap = new BasicPermissionMap(); /** @var \Symfony\Component\Security\Acl\Model\AclProviderInterface $aclProvider */ - $aclProvider = $application->getKernel()->getContainer()->get('security.acl.provider'); + $aclProvider = $application->getKernel()->getContainer()->get('test.security.acl.provider'); $acl = $aclProvider->findAcl($objectIdentity, array($securityIdentity1)); $this->assertTrue($acl->isGranted($permissionMap->getMasks($grantedPermission1, null), array($securityIdentity1))); @@ -95,7 +95,7 @@ public function testSetAclRole() $role = 'ROLE_ADMIN'; $application = $this->getApplication(); - $application->add(new SetAclCommand($application->getKernel()->getContainer()->get('security.acl.provider'))); + $application->add(new SetAclCommand($application->getKernel()->getContainer()->get('test.security.acl.provider'))); $setAclCommand = $application->find('acl:set'); $setAclCommandTester = new CommandTester($setAclCommand); @@ -111,7 +111,7 @@ public function testSetAclRole() $permissionMap = new BasicPermissionMap(); /** @var \Symfony\Component\Security\Acl\Model\AclProviderInterface $aclProvider */ - $aclProvider = $application->getKernel()->getContainer()->get('security.acl.provider'); + $aclProvider = $application->getKernel()->getContainer()->get('test.security.acl.provider'); $acl = $aclProvider->findAcl($objectIdentity, array($roleSecurityIdentity, $userSecurityIdentity)); $this->assertTrue($acl->isGranted($permissionMap->getMasks($grantedPermission, null), array($roleSecurityIdentity))); @@ -137,7 +137,7 @@ public function testSetAclClassScope() $role = 'ROLE_USER'; $application = $this->getApplication(); - $application->add(new SetAclCommand($application->getKernel()->getContainer()->get('security.acl.provider'))); + $application->add(new SetAclCommand($application->getKernel()->getContainer()->get('test.security.acl.provider'))); $setAclCommand = $application->find('acl:set'); $setAclCommandTester = new CommandTester($setAclCommand); @@ -154,7 +154,7 @@ public function testSetAclClassScope() $permissionMap = new BasicPermissionMap(); /** @var \Symfony\Component\Security\Acl\Model\AclProviderInterface $aclProvider */ - $aclProvider = $application->getKernel()->getContainer()->get('security.acl.provider'); + $aclProvider = $application->getKernel()->getContainer()->get('test.security.acl.provider'); $acl1 = $aclProvider->findAcl($objectIdentity1, array($roleSecurityIdentity)); $this->assertTrue($acl1->isGranted($permissionMap->getMasks($grantedPermission, null), array($roleSecurityIdentity))); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Acl/config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Acl/config.yml index 33eadbc7cdf03..49191e01d85c2 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Acl/config.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Acl/config.yml @@ -1,6 +1,9 @@ imports: - { resource: ./../config/framework.yml } +services: + test.security.acl.provider: '@security.acl.provider' + doctrine: dbal: driver: pdo_sqlite diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 38bf0220536d5..9690cf325aa14 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -31,7 +31,7 @@ "symfony/dom-crawler": "~2.8|~3.0|~4.0", "symfony/event-dispatcher": "^3.3.1|~4.0", "symfony/form": "^2.8.18|^3.2.5|~4.0", - "symfony/framework-bundle": "^3.2.8|~4.0", + "symfony/framework-bundle": "^3.4|~4.0", "symfony/http-foundation": "~2.8|~3.0|~4.0", "symfony/security-acl": "~2.8|~3.0", "symfony/translation": "~2.8|~3.0|~4.0", @@ -48,6 +48,7 @@ "conflict": { "symfony/var-dumper": "<3.3", "symfony/event-dispatcher": "<3.3.1", + "symfony/framework-bundle": "<3.4", "symfony/console": "<3.4" }, "suggest": { diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php index f2c1d32eec974..0f61aecc2c5b7 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler; +use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; @@ -43,7 +44,7 @@ public function process(ContainerBuilder $container) } if (1 === $found) { - $container->setAlias('twig.loader', $id); + $container->setAlias('twig.loader', $id)->setPrivate(true); } else { $chainLoader = $container->getDefinition('twig.loader.chain'); krsort($prioritizedLoaders); @@ -54,7 +55,7 @@ public function process(ContainerBuilder $container) } } - $container->setAlias('twig.loader', 'twig.loader.chain'); + $container->setAlias('twig.loader', 'twig.loader.chain')->setPrivate(true); } } } diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index ca0c68d49b02a..f3dd1811c7f16 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -43,8 +43,15 @@ public function load(array $configs, ContainerBuilder $container) $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('twig.xml'); + $container->getDefinition('twig.profile')->setPrivate(true); + $container->getDefinition('twig.runtime.httpkernel')->setPrivate(true); + $container->getDefinition('twig.translation.extractor')->setPrivate(true); + $container->getDefinition('workflow.twig_extension')->setPrivate(true); + $container->getDefinition('twig.exception_listener')->setPrivate(true); + if (class_exists('Symfony\Component\Form\Form')) { $loader->load('form.xml'); + $container->getDefinition('twig.form.renderer')->setPrivate(true); } if (interface_exists('Symfony\Component\Templating\EngineInterface')) { diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml index b1cee0ae381f7..caa799bc346c0 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml @@ -18,7 +18,7 @@ - + diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index bf53c2b2b28f6..8c6a944603333 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -63,7 +63,7 @@ - + @@ -100,7 +100,7 @@ - + @@ -112,16 +112,16 @@ - + - + - + %twig.exception_listener.controller% diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php index 10bcf3e8f66a8..6575f28c9736d 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php @@ -12,6 +12,7 @@ namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; +use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Definition; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigLoaderPass; @@ -55,7 +56,8 @@ public function testMapperPassWithOneTaggedLoaders() ->will($this->returnValue($serviceIds)); $this->builder->expects($this->once()) ->method('setAlias') - ->with('twig.loader', 'test_loader_1'); + ->with('twig.loader', 'test_loader_1') + ->will($this->returnValue(new Alias('test_loader_1'))); $this->pass->process($this->builder); } @@ -85,7 +87,8 @@ public function testMapperPassWithTwoTaggedLoaders() ->will($this->returnValue($this->chainLoader)); $this->builder->expects($this->once()) ->method('setAlias') - ->with('twig.loader', 'twig.loader.chain'); + ->with('twig.loader', 'twig.loader.chain') + ->will($this->returnValue(new Alias('twig.loader.chain'))); $this->pass->process($this->builder); $calls = $this->chainLoader->getMethodCalls(); @@ -121,7 +124,8 @@ public function testMapperPassWithTwoTaggedLoadersWithPriority() ->will($this->returnValue($this->chainLoader)); $this->builder->expects($this->once()) ->method('setAlias') - ->with('twig.loader', 'twig.loader.chain'); + ->with('twig.loader', 'twig.loader.chain') + ->will($this->returnValue(new Alias('twig.loader.chain'))); $this->pass->process($this->builder); $calls = $this->chainLoader->getMethodCalls(); diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index 3b8ca5b99469b..3d5fff2779a10 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -26,20 +26,21 @@ "require-dev": { "symfony/asset": "~2.8|~3.0|~4.0", "symfony/stopwatch": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", "symfony/expression-language": "~2.8|~3.0|~4.0", "symfony/finder": "~2.8|~3.0|~4.0", "symfony/form": "~2.8|~3.0|~4.0", "symfony/routing": "~2.8|~3.0|~4.0", "symfony/templating": "~2.8|~3.0|~4.0", "symfony/yaml": "~2.8|~3.0|~4.0", - "symfony/framework-bundle": "^3.2.8|~4.0", + "symfony/framework-bundle": "^3.3|~4.0", "symfony/web-link": "~3.3|~4.0", "doctrine/annotations": "~1.0", "doctrine/cache": "~1.0" }, "conflict": { - "symfony/dependency-injection": "<3.3" + "symfony/dependency-injection": "<3.4", + "symfony/event-dispatcher": "<3.3.1" }, "autoload": { "psr-4": { "Symfony\\Bundle\\TwigBundle\\": "" }, diff --git a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php index e507bf2d22b70..b0db2e3bc8f22 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php +++ b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php @@ -48,6 +48,7 @@ public function load(array $configs, ContainerBuilder $container) if ($config['toolbar'] || $config['intercept_redirects']) { $loader->load('toolbar.xml'); + $container->getDefinition('web_profiler.debug_toolbar')->setPrivate(true); $container->getDefinition('web_profiler.debug_toolbar')->replaceArgument(5, $config['excluded_ajax_paths']); $container->setParameter('web_profiler.debug_toolbar.intercept_redirects', $config['intercept_redirects']); $container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml index 25f49fc2cd069..16a7022c6d960 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml @@ -7,7 +7,7 @@ - + %web_profiler.debug_toolbar.intercept_redirects% diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index 40ead3bff2564..dd2a4d728f53c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -27,13 +27,13 @@ "require-dev": { "symfony/config": "~3.4|~4.0", "symfony/console": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", "symfony/stopwatch": "~2.8|~3.0|~4.0" }, "conflict": { "symfony/config": "<3.4", - "symfony/dependency-injection": "<3.3", - "symfony/event-dispatcher": "<3.3", + "symfony/dependency-injection": "<3.4", + "symfony/event-dispatcher": "<3.3.1", "symfony/var-dumper": "<3.3" }, "autoload": { diff --git a/src/Symfony/Component/DependencyInjection/Alias.php b/src/Symfony/Component/DependencyInjection/Alias.php index a113f8f7f2c38..ee43bd399f92b 100644 --- a/src/Symfony/Component/DependencyInjection/Alias.php +++ b/src/Symfony/Component/DependencyInjection/Alias.php @@ -15,6 +15,7 @@ class Alias { private $id; private $public; + private $private = false; /** * @param string $id Alias identifier @@ -40,10 +41,43 @@ public function isPublic() * Sets if this Alias is public. * * @param bool $boolean If this Alias should be public + * + * @return $this */ public function setPublic($boolean) { $this->public = (bool) $boolean; + + return $this; + } + + /** + * Sets if this Alias is private. + * + * When set, the "private" state has a higher precedence than "public". + * In version 3.4, a "private" alias always remains publicly accessible, + * but triggers a deprecation notice when accessed from the container, + * so that the alias can be made really private in 4.0. + * + * @param bool $boolean + * + * @return $this + */ + public function setPrivate($boolean) + { + $this->private = (bool) $boolean; + + return $this; + } + + /** + * Whether this alias is private. + * + * @return bool + */ + public function isPrivate() + { + return $this->private; } /** diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php index a43e0cd78f404..815dbcae4915d 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php @@ -39,7 +39,7 @@ public function process(ContainerBuilder $container) { foreach ($container->getDefinitions() as $id => $definition) { // synthetic service is public - if ($definition->isSynthetic() && !$definition->isPublic()) { + if ($definition->isSynthetic() && (!$definition->isPublic() || $definition->isPrivate())) { throw new RuntimeException(sprintf('A synthetic service ("%s") must be public.', $id)); } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php b/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php index d1fe95a0bc7a5..0e9a68e7f0026 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php @@ -49,6 +49,7 @@ public function process(ContainerBuilder $container) if ($container->hasAlias($inner)) { $alias = $container->getAlias($inner); $public = $alias->isPublic(); + $private = $alias->isPrivate(); $container->setAlias($renamedId, new Alias((string) $alias, false)); } else { $decoratedDefinition = $container->getDefinition($inner); @@ -57,6 +58,7 @@ public function process(ContainerBuilder $container) $definition->setAutowiringTypes($types); } $public = $decoratedDefinition->isPublic(); + $private = $decoratedDefinition->isPrivate(); $decoratedDefinition->setPublic(false); $decoratedDefinition->setTags(array()); if ($decoratedDefinition->getAutowiringTypes(false)) { @@ -65,7 +67,7 @@ public function process(ContainerBuilder $container) $container->setDefinition($renamedId, $decoratedDefinition); } - $container->setAlias($inner, new Alias($id, $public)); + $container->setAlias($inner, $id)->setPublic($public && !$private)->setPrivate($private); } } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php index 240e1ab65527f..73f75b30a982c 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php @@ -82,7 +82,7 @@ private function isInlineableDefinition($id, Definition $definition, ServiceRefe return true; } - if ($definition->isDeprecated() || $definition->isPublic() || $definition->isLazy()) { + if ($definition->isDeprecated() || $definition->isPublic() || $definition->isPrivate() || $definition->isLazy()) { return false; } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/RemovePrivateAliasesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/RemovePrivateAliasesPass.php index 5d6d51d6916f3..529dc9e5b37a3 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/RemovePrivateAliasesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/RemovePrivateAliasesPass.php @@ -30,7 +30,7 @@ class RemovePrivateAliasesPass implements CompilerPassInterface public function process(ContainerBuilder $container) { foreach ($container->getAliases() as $id => $alias) { - if ($alias->isPublic()) { + if ($alias->isPublic() || $alias->isPrivate()) { continue; } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php index a8a01be6d5291..7fcf6cc634283 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php @@ -41,7 +41,7 @@ public function process(ContainerBuilder $container) $hasChanged = false; foreach ($container->getDefinitions() as $id => $definition) { - if ($definition->isPublic()) { + if ($definition->isPublic() || $definition->isPrivate()) { continue; } @@ -68,7 +68,8 @@ public function process(ContainerBuilder $container) if (1 === count($referencingAliases) && false === $isReferenced) { $container->setDefinition((string) reset($referencingAliases), $definition); - $definition->setPublic(true); + $definition->setPrivate(reset($referencingAliases)->isPrivate()); + $definition->setPublic(!$definition->isPrivate()); $container->removeDefinition($id); $container->log($this, sprintf('Removed service "%s"; reason: replaces alias %s.', $id, reset($referencingAliases))); } elseif (0 === count($referencingAliases) && false === $isReferenced) { diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php index 30a8f5d048f9a..124bd08b6f92c 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php @@ -58,11 +58,12 @@ public function process(ContainerBuilder $container) } catch (InvalidArgumentException $e) { throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with actual definition "%s".', $definitionId, $targetId), null, $e); } - if ($definition->isPublic()) { + if ($definition->isPublic() || $definition->isPrivate()) { continue; } // Remove private definition and schedule for replacement - $definition->setPublic(true); + $definition->setPublic(!$target->isPrivate()); + $definition->setPrivate($target->isPrivate()); $container->setDefinition($definitionId, $definition); $container->removeDefinition($targetId); $replacements[$targetId] = $definitionId; diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveChildDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveChildDefinitionsPass.php index 4e09ae630f52c..7625377793769 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveChildDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveChildDefinitionsPass.php @@ -12,6 +12,7 @@ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ChildDefinition; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\ExceptionInterface; use Symfony\Component\DependencyInjection\Exception\RuntimeException; @@ -25,6 +26,26 @@ */ class ResolveChildDefinitionsPass extends AbstractRecursivePass { + /** + * {@inheritdoc} + */ + public function process(ContainerBuilder $container) + { + parent::process($container); + + foreach ($container->getDefinitions() as $definition) { + if ($definition->isPrivate()) { + $definition->setPublic(false); + } + } + + foreach ($container->getAliases() as $alias) { + if ($alias->isPrivate()) { + $alias->setPublic(false); + } + } + } + protected function processValue($value, $isRoot = false) { if (!$value instanceof Definition) { @@ -121,6 +142,8 @@ private function doResolveDefinition(ChildDefinition $definition) } if (isset($changes['public'])) { $def->setPublic($definition->isPublic()); + } else { + $def->setPrivate($definition->isPrivate() || $parentDef->isPrivate()); } if (isset($changes['lazy'])) { $def->setLazy($definition->isLazy()); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php index 6e79faba43f04..6946969a2c06f 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php @@ -51,7 +51,7 @@ public function process(ContainerBuilder $container) foreach ($container->getAliases() as $id => $alias) { $aliasId = (string) $alias; if ($aliasId !== $defId = $this->getDefinitionId($aliasId)) { - $container->setAlias($id, new Alias($defId, $alias->isPublic())); + $container->setAlias($id, $defId)->setPublic($alias->isPublic() && !$alias->isPrivate())->setPrivate($alias->isPrivate()); } } } diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 63a7c2b33176b..f053694e9715d 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -806,6 +806,8 @@ public function setAliases(array $aliases) * @param string $alias The alias to create * @param string|Alias $id The service to alias * + * @return Alias + * * @throws InvalidArgumentException if the id is not a string or an Alias * @throws InvalidArgumentException if the alias is for itself */ @@ -825,7 +827,7 @@ public function setAlias($alias, $id) unset($this->definitions[$alias]); - $this->aliasDefinitions[$alias] = $id; + return $this->aliasDefinitions[$alias] = $id; } /** diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index e3ff8e5411ddc..2cfa3f9f481c6 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -35,6 +35,7 @@ class Definition private $configurator; private $tags = array(); private $public = true; + private $private = false; private $synthetic = false; private $abstract = false; private $lazy = false; @@ -616,6 +617,35 @@ public function isPublic() return $this->public; } + /** + * Sets if this service is private. + * + * When set, the "private" state has a higher precedence than "public". + * In version 3.4, a "private" service always remains publicly accessible, + * but triggers a deprecation notice when accessed from the container, + * so that the service can be made really private in 4.0. + * + * @param bool $boolean + * + * @return $this + */ + public function setPrivate($boolean) + { + $this->private = (bool) $boolean; + + return $this; + } + + /** + * Whether this service is private. + * + * @return bool + */ + public function isPrivate() + { + return $this->private; + } + /** * Sets the lazy flag of this service. * diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 87835ee44008e..f32187b1c1bb4 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -1040,11 +1040,17 @@ private function addFileMap() */ private function addPrivateServices() { - if (!$definitions = $this->container->getDefinitions()) { - return ''; + $code = ''; + + $aliases = $this->container->getAliases(); + ksort($aliases); + foreach ($aliases as $id => $alias) { + if ($alias->isPrivate()) { + $code .= ' '.$this->export($id)." => true,\n"; + } } - $code = ''; + $definitions = $this->container->getDefinitions(); ksort($definitions); foreach ($definitions as $id => $definition) { if (!$definition->isPublic()) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php index 23a1915fd777c..cb9a879a05d48 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php @@ -397,6 +397,26 @@ public function testSetAutoconfiguredOnServiceIsParent() $this->assertFalse($container->getDefinition('child1')->isAutoconfigured()); } + public function testPrivateHasHigherPrecedenceThanPublic() + { + $container = new ContainerBuilder(); + + $container->register('foo', 'stdClass') + ->setPrivate(true) + ->setPublic(true) + ; + + $container->setAlias('bar', 'foo') + ->setPrivate(false) + ->setPublic(false) + ; + + $this->process($container); + + $this->assertFalse($container->getDefinition('foo')->isPublic()); + $this->assertFalse($container->getAlias('bar')->isPublic()); + } + /** * @group legacy */ diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index ac8aee2fc596c..4ea8290cfc725 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -778,6 +778,52 @@ public function testDumpHandlesLiteralClassWithRootNamespace() $this->assertInstanceOf('stdClass', $container->get('foo')); } + /** + * @group legacy + * @expectedDeprecation Requesting the "private" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. + * @expectedDeprecation Requesting the "private_alias" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. + * @expectedDeprecation Requesting the "decorated_private" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. + * @expectedDeprecation Requesting the "decorated_private_alias" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. + * @expectedDeprecation Requesting the "private_not_inlined" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. + * @expectedDeprecation Requesting the "private_not_removed" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. + * @expectedDeprecation Requesting the "private_child" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. + * @expectedDeprecation Requesting the "private_parent" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. + */ + public function testLegacyPrivateServices() + { + $container = new ContainerBuilder(); + $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('services_legacy_privates.yml'); + + $container->getDefinition('private')->setPrivate(true); + $container->getDefinition('private_not_inlined')->setPrivate(true); + $container->getDefinition('private_not_removed')->setPrivate(true); + $container->getDefinition('decorated_private')->setPrivate(true); + $container->getDefinition('private_child')->setPrivate(true); + $container->getAlias('decorated_private_alias')->setPrivate(true); + $container->getAlias('private_alias')->setPrivate(true); + + $container->compile(); + $dumper = new PhpDumper($container); + + $this->assertStringEqualsFile(self::$fixturesPath.'/php/services_legacy_privates.php', $dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Legacy_Privates', 'file' => self::$fixturesPath.'/php/services_legacy_privates.php'))); + + require self::$fixturesPath.'/php/services_legacy_privates.php'; + + $container = new \Symfony_DI_PhpDumper_Test_Legacy_Privates(); + + $container->get('private'); + $container->get('private_alias'); + $container->get('alias_to_private'); + $container->get('decorated_private'); + $container->get('decorated_private_alias'); + $container->get('private_not_inlined'); + $container->get('private_not_removed'); + $container->get('private_child'); + $container->get('private_parent'); + $container->get('public_child'); + } + /** * This test checks the trigger of a deprecation note and should not be removed in major releases. * diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php new file mode 100644 index 0000000000000..70e781bdfd9e9 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php @@ -0,0 +1,200 @@ +targetDirs[$i] = $dir = dirname($dir); + } + $this->services = array(); + $this->methodMap = array( + 'bar' => 'getBarService', + 'private' => 'getPrivateService', + 'private_alias' => 'getPrivateAliasService', + 'private_alias_decorator' => 'getPrivateAliasDecoratorService', + 'private_child' => 'getPrivateChildService', + 'private_decorator' => 'getPrivateDecoratorService', + 'private_decorator.inner' => 'getPrivateDecorator_InnerService', + 'private_not_inlined' => 'getPrivateNotInlinedService', + 'private_not_removed' => 'getPrivateNotRemovedService', + 'private_parent' => 'getPrivateParentService', + 'public_child' => 'getPublicChildService', + ); + $this->privates = array( + 'decorated_private' => true, + 'decorated_private_alias' => true, + 'private' => true, + 'private_alias' => true, + 'private_child' => true, + 'private_decorator.inner' => true, + 'private_not_inlined' => true, + 'private_not_removed' => true, + 'private_parent' => true, + ); + $this->aliases = array( + 'alias_to_private' => 'private', + 'decorated_private' => 'private_decorator', + 'decorated_private_alias' => 'private_alias_decorator', + ); + } + + /** + * {@inheritdoc} + */ + public function compile() + { + throw new LogicException('You cannot compile a dumped container that was already compiled.'); + } + + /** + * {@inheritdoc} + */ + public function isCompiled() + { + return true; + } + + /** + * {@inheritdoc} + */ + public function isFrozen() + { + @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the isCompiled() method instead.', __METHOD__), E_USER_DEPRECATED); + + return true; + } + + /** + * Gets the public 'bar' shared service. + * + * @return \stdClass + */ + protected function getBarService() + { + return $this->services['bar'] = new \stdClass(${($_ = isset($this->services['private_not_inlined']) ? $this->services['private_not_inlined'] : $this->services['private_not_inlined'] = new \stdClass()) && false ?: '_'}); + } + + /** + * Gets the public 'private_alias_decorator' shared service. + * + * @return \stdClass + */ + protected function getPrivateAliasDecoratorService() + { + return $this->services['private_alias_decorator'] = new \stdClass(); + } + + /** + * Gets the public 'private_decorator' shared service. + * + * @return \stdClass + */ + protected function getPrivateDecoratorService() + { + return $this->services['private_decorator'] = new \stdClass(); + } + + /** + * Gets the public 'public_child' shared service. + * + * @return \stdClass + */ + protected function getPublicChildService() + { + return $this->services['public_child'] = new \stdClass(); + } + + /** + * Gets the private 'private' shared service. + * + * @return \stdClass + */ + protected function getPrivateService() + { + return $this->services['private'] = new \stdClass(); + } + + /** + * Gets the private 'private_alias' shared service. + * + * @return \stdClass + */ + protected function getPrivateAliasService() + { + return $this->services['private_alias'] = new \stdClass(); + } + + /** + * Gets the private 'private_child' shared service. + * + * @return \stdClass + */ + protected function getPrivateChildService() + { + return $this->services['private_child'] = new \stdClass(); + } + + /** + * Gets the private 'private_decorator.inner' shared service. + * + * @return \stdClass + */ + protected function getPrivateDecorator_InnerService() + { + return $this->services['private_decorator.inner'] = new \stdClass(); + } + + /** + * Gets the private 'private_not_inlined' shared service. + * + * @return \stdClass + */ + protected function getPrivateNotInlinedService() + { + return $this->services['private_not_inlined'] = new \stdClass(); + } + + /** + * Gets the private 'private_not_removed' shared service. + * + * @return \stdClass + */ + protected function getPrivateNotRemovedService() + { + return $this->services['private_not_removed'] = new \stdClass(); + } + + /** + * Gets the private 'private_parent' shared service. + * + * @return \stdClass + */ + protected function getPrivateParentService() + { + return $this->services['private_parent'] = new \stdClass(); + } +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_legacy_privates.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_legacy_privates.yml new file mode 100644 index 0000000000000..ac54a57dff013 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_legacy_privates.yml @@ -0,0 +1,28 @@ +services: + + foo: {class: stdClass, public: false} + + bar: + class: stdClass + arguments: [ '@private_not_inlined' ] + + private: {class: stdClass, public: false} + decorated_private: {class: stdClass} + decorated_private_alias: '@foo' + alias_to_private: '@private' + private_alias: {alias: foo, public: false} + + private_decorator: + class: stdClass + decorates: 'decorated_private' + + private_alias_decorator: + class: stdClass + decorates: 'decorated_private_alias' + + private_not_inlined: {class: stdClass, public: false} + private_not_removed: {class: stdClass, public: false} + + private_child: {parent: foo} + private_parent: {parent: private} + public_child: {parent: private, public: true}