[DI] Deprecate autowiring-types in favor of aliases #21494

Merged
merged 1 commit into from Feb 1, 2017
Jump to file
+141 −87
Split
View
@@ -14,6 +14,23 @@ Debug
DependencyInjection
-------------------
+ * Autowiring-types have been deprecated, use aliases instead.
+
+ Before:
+
+ ```xml
+ <service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false">
+ <autowiring-type>Doctrine\Common\Annotations\Reader</autowiring-type>
+ </service>
+ ```
+
+ After:
+
+ ```xml
+ <service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false" />
+ <service id="Doctrine\Common\Annotations\Reader" alias="annotations.reader" public="false" />
+ ```
+
* The `Reference` and `Alias` classes do not make service identifiers lowercase anymore.
* Case insensitivity of service identifiers is deprecated and will be removed in 4.0.
View
@@ -24,6 +24,23 @@ Debug
DependencyInjection
-------------------
+ * Autowiring-types have been removed, use aliases instead.
+
+ Before:
+
+ ```xml
+ <service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false">
+ <autowiring-type>Doctrine\Common\Annotations\Reader</autowiring-type>
+ </service>
+ ```
+
+ After:
+
+ ```xml
+ <service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false" />
+ <service id="Doctrine\Common\Annotations\Reader" alias="annotations.reader" public="false" />
+ ```
+
* Service identifiers are now case sensitive.
* The `Reference` and `Alias` classes do not make service identifiers lowercase anymore.
@@ -220,10 +220,9 @@ private function getContainerDefinitionData(Definition $definition, $omitTags =
'shared' => $definition->isShared(),
'abstract' => $definition->isAbstract(),
'autowire' => $definition->isAutowired(),
- 'autowiring_types' => array(),
);
- foreach ($definition->getAutowiringTypes() as $autowiringType) {
+ foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
$data['autowiring_types'][] = $autowiringType;
}
@@ -185,7 +185,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
."\n".'- Autowired: '.($definition->isAutowired() ? 'yes' : 'no')
;
- foreach ($definition->getAutowiringTypes() as $autowiringType) {
+ foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
$output .= "\n".'- Autowiring Type: `'.$autowiringType.'`';
}
@@ -294,8 +294,9 @@ protected function describeContainerDefinition(Definition $definition, array $op
$tableRows[] = array('Abstract', $definition->isAbstract() ? 'yes' : 'no');
$tableRows[] = array('Autowired', $definition->isAutowired() ? 'yes' : 'no');
- $autowiringTypes = $definition->getAutowiringTypes();
- $tableRows[] = array('Autowiring Types', $autowiringTypes ? implode(', ', $autowiringTypes) : '-');
+ if ($autowiringTypes = $definition->getAutowiringTypes(false)) {
+ $tableRows[] = array('Autowiring Types', implode(', ', $autowiringTypes));
+ }
if ($definition->getFile()) {
$tableRows[] = array('Required File', $definition->getFile() ? $definition->getFile() : '-');
@@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
+use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
@@ -25,8 +26,8 @@ public function process(ContainerBuilder $container)
}
if ($container->hasAlias('templating')) {
- $definition = $container->findDefinition('templating');
- $definition->setAutowiringTypes(array(ComponentEngineInterface::class, FrameworkBundleEngineInterface::class));
+ $container->setAlias(ComponentEngineInterface::class, new Alias('templating', false));
+ $container->setAlias(FrameworkBundleEngineInterface::class, new Alias('templating', false));
}
if ($container->hasDefinition('templating.engine.php')) {
@@ -1096,8 +1096,8 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
->getDefinition('annotations.cached_reader')
->replaceArgument(1, new Reference($cacheService))
->replaceArgument(2, $config['debug'])
- ->addAutowiringType(Reader::class)
;
+ $container->setAlias(Reader::class, new Alias('annotations.cached_reader', false));
} else {
$container->removeDefinition('annotations.cached_reader');
}
@@ -5,9 +5,8 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
- <service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false">
- <autowiring-type>Doctrine\Common\Annotations\Reader</autowiring-type>
- </service>
+ <service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false" />
+ <service id="Doctrine\Common\Annotations\Reader" alias="annotations.reader" public="false" />
<service id="annotations.cached_reader" class="Doctrine\Common\Annotations\CachedReader" public="false">
<argument type="service" id="annotations.reader" />
@@ -7,9 +7,9 @@
<services>
<service id="event_dispatcher" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">
<argument type="service" id="service_container" />
- <autowiring-type>Symfony\Component\EventDispatcher\EventDispatcherInterface</autowiring-type>
- <autowiring-type>Symfony\Component\EventDispatcher\EventDispatcher</autowiring-type>
</service>
+ <service id="Symfony\Component\EventDispatcher\EventDispatcherInterface" alias="event_dispatcher" public="false" />
+ <service id="Symfony\Component\EventDispatcher\EventDispatcher" alias="event_dispatcher" public="false" />
<service id="http_kernel" class="Symfony\Component\HttpKernel\HttpKernel">
<argument type="service" id="event_dispatcher" />
@@ -40,10 +40,8 @@
<argument type="collection" />
</service>
- <service id="service_container" synthetic="true">
- <autowiring-type>Symfony\Component\DependencyInjection\ContainerInterface</autowiring-type>
- <autowiring-type>Symfony\Component\DependencyInjection\Container</autowiring-type>
- </service>
+ <service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false" />
+ <service id="Symfony\Component\DependencyInjection\Container" alias="service_container" public="false" />
<service id="kernel" synthetic="true" />
@@ -17,9 +17,8 @@
<call method="setConfigCacheFactory">
<argument type="service" id="config_cache_factory" />
</call>
-
- <autowiring-type>Symfony\Component\Translation\TranslatorInterface</autowiring-type>
</service>
+ <service id="Symfony\Component\Translation\TranslatorInterface" alias="translator" public="false" />
<service id="translator.logging" class="Symfony\Component\Translation\LoggingTranslator" public="false">
<argument type="service" id="translator.logging.inner" />
@@ -11,7 +11,6 @@
"shared": true,
"abstract": true,
"autowire": false,
- "autowiring_types": [],
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
"factory_method": "get",
@@ -3,9 +3,9 @@
Information for Service "service_1"
===================================
- ------------------ -----------------------------
+ ---------------- -----------------------------
 Option   Value 
- ------------------ -----------------------------
+ ---------------- -----------------------------
Service ID service_1
Class Full\Qualified\Class1
Tags -
@@ -15,7 +15,6 @@
Shared yes
Abstract yes
Autowired no
- Autowiring Types -
Factory Class Full\Qualified\FactoryClass
Factory Method get
- ------------------ -----------------------------
+ ---------------- -----------------------------
@@ -11,7 +11,6 @@
"shared": true,
"abstract": false,
"autowire": false,
- "autowiring_types": [],
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get",
@@ -3,9 +3,9 @@
Information for Service "service_2"
===================================
- ------------------ ---------------------------------
+ ----------------- ---------------------------------
 Option   Value 
- ------------------ ---------------------------------
+ ----------------- ---------------------------------
Service ID service_2
Class Full\Qualified\Class2
Tags tag1 (attr1: val1, attr2: val2)
@@ -18,8 +18,7 @@
Shared yes
Abstract no
Autowired no
- Autowiring Types -
Required File /path/to/file
Factory Service factory.service
Factory Method get
- ------------------ ---------------------------------
+ ----------------- ---------------------------------
@@ -14,7 +14,6 @@
],
"autowire": false,
- "autowiring_types": [],
"arguments": [
{
"type": "service",
@@ -29,7 +28,6 @@
"shared": true,
"abstract": false,
"autowire": false,
- "autowiring_types": [],
"arguments": [
"arg1",
"arg2"
@@ -13,8 +13,7 @@
"tags": [
],
- "autowire": false,
- "autowiring_types": []
+ "autowire": false
}
},
"aliases": {
@@ -13,8 +13,7 @@
"tags": [
],
- "autowire": false,
- "autowiring_types": []
+ "autowire": false
},
"definition_2": {
"class": "Full\\Qualified\\Class2",
@@ -50,8 +49,7 @@
"calls": [
"setMailer"
],
- "autowire": false,
- "autowiring_types": []
+ "autowire": false
}
},
"aliases": {
@@ -34,8 +34,7 @@
"calls": [
"setMailer"
],
- "autowire": false,
- "autowiring_types": []
+ "autowire": false
}
},
"aliases": [
@@ -13,8 +13,7 @@
],
"factory_service": "factory.service",
"factory_method": "get",
- "autowire": false,
- "autowiring_types": []
+ "autowire": false
}
],
"tag2": [
@@ -31,8 +30,7 @@
],
"factory_service": "factory.service",
"factory_method": "get",
- "autowire": false,
- "autowiring_types": []
+ "autowire": false
}
]
}
@@ -11,6 +11,5 @@
"tags": [
],
- "autowire": false,
- "autowiring_types": []
+ "autowire": false
}
@@ -1,6 +1,6 @@
- ------------------ -----------------------------
+ ---------------- -----------------------------
 Option   Value 
- ------------------ -----------------------------
+ ---------------- -----------------------------
Service ID -
Class Full\Qualified\Class1
Tags -
@@ -10,8 +10,7 @@
Shared yes
Abstract yes
Autowired no
- Autowiring Types -
Factory Class Full\Qualified\FactoryClass
Factory Method get
- ------------------ -----------------------------
+ ---------------- -----------------------------
@@ -32,6 +32,5 @@
"calls": [
"setMailer"
],
- "autowire": false,
- "autowiring_types": []
+ "autowire": false
}
@@ -1,6 +1,6 @@
- ------------------ ---------------------------------
+ ----------------- ---------------------------------
 Option   Value 
- ------------------ ---------------------------------
+ ----------------- ---------------------------------
Service ID -
Class Full\Qualified\Class2
Tags tag1 (attr1: val1, attr2: val2)
@@ -13,9 +13,8 @@
Shared yes
Abstract no
Autowired no
- Autowiring Types -
Required File /path/to/file
Factory Service factory.service
Factory Method get
- ------------------ ---------------------------------
+ ----------------- ---------------------------------
@@ -6,7 +6,6 @@
"shared": true,
"abstract": true,
"autowire": false,
- "autowiring_types": [],
"arguments": [
{
"type": "service",
@@ -21,7 +20,6 @@
"shared": true,
"abstract": false,
"autowire": false,
- "autowiring_types": [],
"arguments": [
"arg1",
"arg2"
@@ -1,6 +1,6 @@
- ------------------ -----------------------------
+ ---------------- -----------------------------
 Option   Value 
- ------------------ -----------------------------
+ ---------------- -----------------------------
Service ID -
Class Full\Qualified\Class1
Tags -
@@ -10,11 +10,10 @@
Shared yes
Abstract yes
Autowired no
- Autowiring Types -
Factory Class Full\Qualified\FactoryClass
Factory Method get
Arguments Service(definition2)
%parameter%
Inlined Service
- ------------------ -----------------------------
+ ---------------- -----------------------------
@@ -6,7 +6,6 @@
"shared": true,
"abstract": false,
"autowire": false,
- "autowiring_types": [],
"arguments": [],
"file": "\/path\/to\/file",
"factory_service": "factory.service",
Oops, something went wrong.