diff --git a/UPGRADE-3.3.md b/UPGRADE-3.3.md
index 1269051076e02..0aa94f4af57e6 100644
--- a/UPGRADE-3.3.md
+++ b/UPGRADE-3.3.md
@@ -14,6 +14,23 @@ Debug
DependencyInjection
-------------------
+ * Autowiring-types have been deprecated, use aliases instead.
+
+ Before:
+
+ ```xml
+
+ Doctrine\Common\Annotations\Reader
+
+ ```
+
+ After:
+
+ ```xml
+
+
+ ```
+
* 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.
diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md
index 1ff703c8e9486..22c732a22ebc8 100644
--- a/UPGRADE-4.0.md
+++ b/UPGRADE-4.0.md
@@ -24,6 +24,23 @@ Debug
DependencyInjection
-------------------
+ * Autowiring-types have been removed, use aliases instead.
+
+ Before:
+
+ ```xml
+
+ Doctrine\Common\Annotations\Reader
+
+ ```
+
+ After:
+
+ ```xml
+
+
+ ```
+
* Service identifiers are now case sensitive.
* The `Reference` and `Alias` classes do not make service identifiers lowercase anymore.
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
index 1bb51867da10a..0860132ad17fc 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
@@ -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;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
index d7b48cef8d7f1..c0319aad6bb19 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
@@ -185,8 +185,8 @@ protected function describeContainerDefinition(Definition $definition, array $op
."\n".'- Autowired: '.($definition->isAutowired() ? 'yes' : 'no')
;
- foreach ($definition->getAutowiringTypes() as $autowiringType) {
- $output .= "\n" . '- Autowiring Type: `' . $autowiringType . '`';
+ foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
+ $output .= "\n".'- Autowiring Type: `'.$autowiringType.'`';
}
if (isset($options['show_arguments']) && $options['show_arguments']) {
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
index 8ccdef4fca83d..bb7a76ab0c676 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
@@ -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() : '-');
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php
index 4ef67a42b6fe6..722a014373bd3 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php
@@ -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')) {
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 30be027e02999..7eec06b7d4993 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.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');
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml
index a2a0fb4065329..c0e5532381dff 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml
@@ -5,9 +5,8 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-
- Doctrine\Common\Annotations\Reader
-
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml
index 1ebca5caf3390..c4dfd51afe6f2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml
@@ -7,9 +7,9 @@
- Symfony\Component\EventDispatcher\EventDispatcherInterface
- Symfony\Component\EventDispatcher\EventDispatcher
+
+
@@ -40,10 +40,8 @@
-
- Symfony\Component\DependencyInjection\ContainerInterface
- Symfony\Component\DependencyInjection\Container
-
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml
index 75b77914bdfe9..6cd41fb882f3e 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml
@@ -17,9 +17,8 @@
-
- Symfony\Component\Translation\TranslatorInterface
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.json
index 9efbde5a86385..09260d6159036 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.json
@@ -11,7 +11,6 @@
"shared": true,
"abstract": true,
"autowire": false,
- "autowiring_types": [],
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
"factory_method": "get",
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.txt
index 52d2520a87717..75347e1a0e431 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.txt
@@ -3,19 +3,18 @@
[33mInformation for Service "[39m[32mservice_1[39m[33m"[39m
[33m===================================[39m
- ------------------ -----------------------------
- [32m Option [39m [32m Value [39m
- ------------------ -----------------------------
- Service ID service_1
- Class Full\Qualified\Class1
- Tags -
- Public yes
- Synthetic no
- Lazy yes
- Shared yes
- Abstract yes
- Autowired no
- Autowiring Types -
- Factory Class Full\Qualified\FactoryClass
- Factory Method get
- ------------------ -----------------------------
\ No newline at end of file
+ ---------------- -----------------------------
+ [32m Option [39m [32m Value [39m
+ ---------------- -----------------------------
+ Service ID service_1
+ Class Full\Qualified\Class1
+ Tags -
+ Public yes
+ Synthetic no
+ Lazy yes
+ Shared yes
+ Abstract yes
+ Autowired no
+ Factory Class Full\Qualified\FactoryClass
+ Factory Method get
+ ---------------- -----------------------------
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_2.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_2.json
index 9f89e47dc2661..03b4f36e13616 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_2.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_2.json
@@ -11,7 +11,6 @@
"shared": true,
"abstract": false,
"autowire": false,
- "autowiring_types": [],
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get",
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_2.txt
index f386f4540e5df..dd639178f6805 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_2.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_2.txt
@@ -3,23 +3,22 @@
[33mInformation for Service "[39m[32mservice_2[39m[33m"[39m
[33m===================================[39m
- ------------------ ---------------------------------
- [32m Option [39m [32m Value [39m
- ------------------ ---------------------------------
- Service ID service_2
- Class Full\Qualified\Class2
- Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
- tag1 ([32mattr3[39m: val3)
- tag2
- Calls setMailer
- Public no
- Synthetic yes
- Lazy no
- Shared yes
- Abstract no
- Autowired no
- Autowiring Types -
- Required File /path/to/file
- Factory Service factory.service
- Factory Method get
- ------------------ ---------------------------------
\ No newline at end of file
+ ----------------- ---------------------------------
+ [32m Option [39m [32m Value [39m
+ ----------------- ---------------------------------
+ Service ID service_2
+ Class Full\Qualified\Class2
+ Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
+ tag1 ([32mattr3[39m: val3)
+ tag2
+ Calls setMailer
+ Public no
+ Synthetic yes
+ Lazy no
+ Shared yes
+ Abstract no
+ Autowired no
+ Required File /path/to/file
+ Factory Service factory.service
+ Factory Method get
+ ----------------- ---------------------------------
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json
index ff2db6858d002..8678c9f2ccb62 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json
@@ -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"
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json
index 170dfa2887e7c..d970cbc06ff82 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json
@@ -13,8 +13,7 @@
"tags": [
],
- "autowire": false,
- "autowiring_types": []
+ "autowire": false
}
},
"aliases": {
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json
index fe2b183901904..ceb490e3f5431 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json
@@ -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": {
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json
index a25a34b44a89d..0b2ecdb584dbc 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json
@@ -34,8 +34,7 @@
"calls": [
"setMailer"
],
- "autowire": false,
- "autowiring_types": []
+ "autowire": false
}
},
"aliases": [
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json
index 25138d78fd42c..34b52ef6f1d72 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json
@@ -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
}
]
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json
index d11d6e92d49fc..9be50bc4dcb38 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json
@@ -11,6 +11,5 @@
"tags": [
],
- "autowire": false,
- "autowiring_types": []
+ "autowire": false
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt
index f74cdbbccd5cc..596d918579071 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt
@@ -1,17 +1,16 @@
- ------------------ -----------------------------
- [32m Option [39m [32m Value [39m
- ------------------ -----------------------------
- Service ID -
- Class Full\Qualified\Class1
- Tags -
- Public yes
- Synthetic no
- Lazy yes
- Shared yes
- Abstract yes
- Autowired no
- Autowiring Types -
- Factory Class Full\Qualified\FactoryClass
- Factory Method get
- ------------------ -----------------------------
+ ---------------- -----------------------------
+ [32m Option [39m [32m Value [39m
+ ---------------- -----------------------------
+ Service ID -
+ Class Full\Qualified\Class1
+ Tags -
+ Public yes
+ Synthetic no
+ Lazy yes
+ Shared yes
+ Abstract yes
+ Autowired no
+ Factory Class Full\Qualified\FactoryClass
+ Factory Method get
+ ---------------- -----------------------------
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.json
index 8a6611a37cd7d..bfc93101e7464 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.json
@@ -32,6 +32,5 @@
"calls": [
"setMailer"
],
- "autowire": false,
- "autowiring_types": []
+ "autowire": false
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt
index cee9d8ff7d0d3..512845c9ecf3d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt
@@ -1,21 +1,20 @@
- ------------------ ---------------------------------
- [32m Option [39m [32m Value [39m
- ------------------ ---------------------------------
- Service ID -
- Class Full\Qualified\Class2
- Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
- tag1 ([32mattr3[39m: val3)
- tag2
- Calls setMailer
- Public no
- Synthetic yes
- Lazy no
- Shared yes
- Abstract no
- Autowired no
- Autowiring Types -
- Required File /path/to/file
- Factory Service factory.service
- Factory Method get
- ------------------ ---------------------------------
+ ----------------- ---------------------------------
+ [32m Option [39m [32m Value [39m
+ ----------------- ---------------------------------
+ Service ID -
+ Class Full\Qualified\Class2
+ Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
+ tag1 ([32mattr3[39m: val3)
+ tag2
+ Calls setMailer
+ Public no
+ Synthetic yes
+ Lazy no
+ Shared yes
+ Abstract no
+ Autowired no
+ Required File /path/to/file
+ Factory Service factory.service
+ Factory Method get
+ ----------------- ---------------------------------
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json
index 0fd51dcde91ba..7ac1ac0ff1be7 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json
@@ -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"
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt
index d6e39a5aa85a1..9d339b517e522 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt
@@ -1,20 +1,19 @@
- ------------------ -----------------------------
- [32m Option [39m [32m Value [39m
- ------------------ -----------------------------
- Service ID -
- Class Full\Qualified\Class1
- Tags -
- Public yes
- Synthetic no
- Lazy yes
- Shared yes
- Abstract yes
- Autowired no
- Autowiring Types -
- Factory Class Full\Qualified\FactoryClass
- Factory Method get
- Arguments Service(definition2)
- %parameter%
- Inlined Service
- ------------------ -----------------------------
+ ---------------- -----------------------------
+ [32m Option [39m [32m Value [39m
+ ---------------- -----------------------------
+ Service ID -
+ Class Full\Qualified\Class1
+ Tags -
+ Public yes
+ Synthetic no
+ Lazy yes
+ Shared yes
+ Abstract yes
+ Autowired no
+ Factory Class Full\Qualified\FactoryClass
+ Factory Method get
+ Arguments Service(definition2)
+ %parameter%
+ Inlined Service
+ ---------------- -----------------------------
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.json
index a0f6e235de62c..7385e98f11ea5 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.json
@@ -6,7 +6,6 @@
"shared": true,
"abstract": false,
"autowire": false,
- "autowiring_types": [],
"arguments": [],
"file": "\/path\/to\/file",
"factory_service": "factory.service",
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.txt
index cee9d8ff7d0d3..512845c9ecf3d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.txt
@@ -1,21 +1,20 @@
- ------------------ ---------------------------------
- [32m Option [39m [32m Value [39m
- ------------------ ---------------------------------
- Service ID -
- Class Full\Qualified\Class2
- Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
- tag1 ([32mattr3[39m: val3)
- tag2
- Calls setMailer
- Public no
- Synthetic yes
- Lazy no
- Shared yes
- Abstract no
- Autowired no
- Autowiring Types -
- Required File /path/to/file
- Factory Service factory.service
- Factory Method get
- ------------------ ---------------------------------
+ ----------------- ---------------------------------
+ [32m Option [39m [32m Value [39m
+ ----------------- ---------------------------------
+ Service ID -
+ Class Full\Qualified\Class2
+ Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
+ tag1 ([32mattr3[39m: val3)
+ tag2
+ Calls setMailer
+ Public no
+ Synthetic yes
+ Lazy no
+ Shared yes
+ Abstract no
+ Autowired no
+ Required File /path/to/file
+ Factory Service factory.service
+ Factory Method get
+ ----------------- ---------------------------------
diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md
index e41bccbd8548a..c6ce00308fd8d 100644
--- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md
+++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md
@@ -4,6 +4,7 @@ CHANGELOG
3.3.0
-----
+ * deprecated autowiring-types, use aliases instead
* [EXPERIMENTAL] added support for getter-injection
* added support for omitting the factory class name in a service definition if the definition class is set
* deprecated case insensitivity of service identifiers
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
index de2d57a84d3dd..83cb204822f5e 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
@@ -245,6 +245,13 @@ private function autowireMethod(\ReflectionMethod $reflectionMethod, array $argu
continue;
}
+ if ($this->container->has($typeName) && !$this->container->findDefinition($typeName)->isAbstract()) {
+ $arguments[$index] = new Reference($typeName);
+ $didAutowire = true;
+
+ continue;
+ }
+
if (null === $this->types) {
$this->populateAvailableTypes();
}
@@ -332,7 +339,7 @@ private function populateAvailableType($id, Definition $definition)
return;
}
- foreach ($definition->getAutowiringTypes() as $type) {
+ foreach ($definition->getAutowiringTypes(false) as $type) {
$this->definedTypes[$type] = true;
$this->types[$type] = $id;
}
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php b/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php
index 8edb717b4cc40..d1fe95a0bc7a5 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php
@@ -53,11 +53,15 @@ public function process(ContainerBuilder $container)
} else {
$decoratedDefinition = $container->getDefinition($inner);
$definition->setTags(array_merge($decoratedDefinition->getTags(), $definition->getTags()));
- $definition->setAutowiringTypes(array_merge($decoratedDefinition->getAutowiringTypes(), $definition->getAutowiringTypes()));
+ if ($types = array_merge($decoratedDefinition->getAutowiringTypes(false), $definition->getAutowiringTypes(false))) {
+ $definition->setAutowiringTypes($types);
+ }
$public = $decoratedDefinition->isPublic();
$decoratedDefinition->setPublic(false);
$decoratedDefinition->setTags(array());
- $decoratedDefinition->setAutowiringTypes(array());
+ if ($decoratedDefinition->getAutowiringTypes(false)) {
+ $decoratedDefinition->setAutowiringTypes(array());
+ }
$container->setDefinition($renamedId, $decoratedDefinition);
}
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
index eddecfeb4c365..c21a58f6b7b39 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
@@ -53,9 +53,9 @@ public function __construct()
new ResolveFactoryClassPass(),
new FactoryReturnTypePass($resolveClassPass),
new CheckDefinitionValidityPass(),
+ new AutowirePass(),
new ResolveReferencesToAliasesPass(),
new ResolveInvalidReferencesPass(),
- new AutowirePass(),
new AnalyzeServiceReferencesPass(true),
new CheckCircularReferencesPass(),
new CheckReferenceValidityPass(),
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php
index 7839111539d2c..7c9eac288180e 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php
@@ -90,7 +90,9 @@ private function doResolveDefinition(ChildDefinition $definition)
$def->setMethodCalls($parentDef->getMethodCalls());
$def->setOverriddenGetters($parentDef->getOverriddenGetters());
$def->setProperties($parentDef->getProperties());
- $def->setAutowiringTypes($parentDef->getAutowiringTypes());
+ if ($parentDef->getAutowiringTypes(false)) {
+ $def->setAutowiringTypes($parentDef->getAutowiringTypes(false));
+ }
if ($parentDef->isDeprecated()) {
$def->setDeprecated(true, $parentDef->getDeprecationMessage('%service_id%'));
}
@@ -167,7 +169,7 @@ private function doResolveDefinition(ChildDefinition $definition)
}
// merge autowiring types
- foreach ($definition->getAutowiringTypes() as $autowiringType) {
+ foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
$def->addAutowiringType($autowiringType);
}
diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php
index 6329154b9ef12..66c48a355c6ad 100644
--- a/src/Symfony/Component/DependencyInjection/Definition.php
+++ b/src/Symfony/Component/DependencyInjection/Definition.php
@@ -679,9 +679,13 @@ public function getConfigurator()
* @param string[] $types
*
* @return $this
+ *
+ * @deprecated since version 3.3, to be removed in 4.0.
*/
public function setAutowiringTypes(array $types)
{
+ @trigger_error('Autowiring-types are deprecated since Symfony 3.3 and will be removed in 4.0. Use aliases instead.', E_USER_DEPRECATED);
+
$this->autowiringTypes = array();
foreach ($types as $type) {
@@ -750,9 +754,15 @@ public function setAutowiredMethods(array $autowiredMethods)
* Gets autowiring types that will default to this definition.
*
* @return string[]
+ *
+ * @deprecated since version 3.3, to be removed in 4.0.
*/
- public function getAutowiringTypes()
+ public function getAutowiringTypes(/*$triggerDeprecation = true*/)
{
+ if (1 > func_num_args() || func_get_arg(0)) {
+ @trigger_error('Autowiring-types are deprecated since Symfony 3.3 and will be removed in 4.0. Use aliases instead.', E_USER_DEPRECATED);
+ }
+
return array_keys($this->autowiringTypes);
}
@@ -762,9 +772,13 @@ public function getAutowiringTypes()
* @param string $type
*
* @return $this
+ *
+ * @deprecated since version 3.3, to be removed in 4.0.
*/
public function addAutowiringType($type)
{
+ @trigger_error(sprintf('Autowiring-types are deprecated since Symfony 3.3 and will be removed in 4.0. Use aliases instead for "%s".', $type), E_USER_DEPRECATED);
+
$this->autowiringTypes[$type] = true;
return $this;
@@ -776,9 +790,13 @@ public function addAutowiringType($type)
* @param string $type
*
* @return $this
+ *
+ * @deprecated since version 3.3, to be removed in 4.0.
*/
public function removeAutowiringType($type)
{
+ @trigger_error(sprintf('Autowiring-types are deprecated since Symfony 3.3 and will be removed in 4.0. Use aliases instead for "%s".', $type), E_USER_DEPRECATED);
+
unset($this->autowiringTypes[$type]);
return $this;
@@ -790,9 +808,13 @@ public function removeAutowiringType($type)
* @param string $type
*
* @return bool
+ *
+ * @deprecated since version 3.3, to be removed in 4.0.
*/
public function hasAutowiringType($type)
{
+ @trigger_error(sprintf('Autowiring-types are deprecated since Symfony 3.3 and will be removed in 4.0. Use aliases instead for "%s".', $type), E_USER_DEPRECATED);
+
return isset($this->autowiringTypes[$type]);
}
}
diff --git a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
index 03097e3d137ff..73fb33c2aeadd 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
@@ -201,7 +201,7 @@ private function addService($definition, $id, \DOMElement $parent)
$service->setAttribute('autowire', 'true');
}
- foreach ($definition->getAutowiringTypes() as $autowiringTypeValue) {
+ foreach ($definition->getAutowiringTypes(false) as $autowiringTypeValue) {
$autowiringType = $this->document->createElement('autowiring-type');
$autowiringType->appendChild($this->document->createTextNode($autowiringTypeValue));
diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
index 87a6024506cec..b0ab9d6a2c9dd 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
@@ -107,7 +107,7 @@ private function addService($id, $definition)
}
$autowiringTypesCode = '';
- foreach ($definition->getAutowiringTypes() as $autowiringType) {
+ foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
$autowiringTypesCode .= sprintf(" - %s\n", $this->dumper->dump($autowiringType));
}
if ($autowiringTypesCode) {
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php
index d1a596134b87e..e9a8c2fc68356 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php
@@ -191,7 +191,7 @@ public function testTypeNotGuessableWithTypeSet()
$container = new ContainerBuilder();
$container->register('a1', __NAMESPACE__.'\Foo');
- $container->register('a2', __NAMESPACE__.'\Foo')->addAutowiringType(__NAMESPACE__.'\Foo');
+ $container->register(Foo::class, Foo::class);
$aDefinition = $container->register('a', __NAMESPACE__.'\NotGuessableArgument');
$aDefinition->setAutowired(true);
@@ -199,7 +199,7 @@ public function testTypeNotGuessableWithTypeSet()
$pass->process($container);
$this->assertCount(1, $container->getDefinition('a')->getArguments());
- $this->assertEquals('a2', (string) $container->getDefinition('a')->getArgument(0));
+ $this->assertEquals(Foo::class, (string) $container->getDefinition('a')->getArgument(0));
}
public function testWithTypeSet()
@@ -207,7 +207,8 @@ public function testWithTypeSet()
$container = new ContainerBuilder();
$container->register('c1', __NAMESPACE__.'\CollisionA');
- $container->register('c2', __NAMESPACE__.'\CollisionB')->addAutowiringType(__NAMESPACE__.'\CollisionInterface');
+ $container->register('c2', __NAMESPACE__.'\CollisionB');
+ $container->setAlias(CollisionInterface::class, 'c2');
$aDefinition = $container->register('a', __NAMESPACE__.'\CannotBeAutowired');
$aDefinition->setAutowired(true);
@@ -215,7 +216,7 @@ public function testWithTypeSet()
$pass->process($container);
$this->assertCount(1, $container->getDefinition('a')->getArguments());
- $this->assertEquals('c2', (string) $container->getDefinition('a')->getArgument(0));
+ $this->assertEquals(CollisionInterface::class, (string) $container->getDefinition('a')->getArgument(0));
}
public function testCreateDefinition()
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php
index fbdd3af372149..9712ac474da88 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php
@@ -143,6 +143,9 @@ public function testProcessMovesTagsFromDecoratedDefinitionToDecoratingDefinitio
$this->assertEquals(array('bar' => array('attr' => 'baz'), 'foobar' => array('attr' => 'bar')), $container->getDefinition('baz')->getTags());
}
+ /**
+ * @group legacy
+ */
public function testProcessMergesAutowiringTypesInDecoratingDefinitionAndRemoveThemFromDecoratedDefinition()
{
$container = new ContainerBuilder();
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php
index 1dc96e7396550..28a8495227cad 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php
@@ -322,6 +322,9 @@ public function testDecoratedServiceCanOverwriteDeprecatedParentStatus()
$this->assertFalse($container->getDefinition('decorated_deprecated_parent')->isDeprecated());
}
+ /**
+ * @group legacy
+ */
public function testProcessMergeAutowiringTypes()
{
$container = new ContainerBuilder();
diff --git a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php
index ee6f42ea425d5..0fb736427ca11 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php
@@ -313,6 +313,9 @@ public function testAutowired()
$this->assertTrue($def->isAutowired());
}
+ /**
+ * @group legacy
+ */
public function testTypes()
{
$def = new Definition('stdClass');
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container24.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container24.php
index 3e033059aee68..cba10b526b2a8 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container24.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container24.php
@@ -7,8 +7,6 @@
$container
->register('foo', 'Foo')
->setAutowired(true)
- ->addAutowiringType('A')
- ->addAutowiringType('B')
;
return $container;
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml
index 476588aa4df97..9f01ead06783d 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml
@@ -1,9 +1,6 @@
-
- A
- B
-
+
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml
index 1894077e4b42f..174bee32f8809 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml
@@ -3,6 +3,3 @@ services:
foo:
class: Foo
autowire: true
- autowiring_types:
- - A
- - B
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
index 4fcd667f578d1..45c6a87e86542 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
@@ -554,6 +554,9 @@ public function testLoadInlinedServices()
$this->assertSame('configureBar', $barConfigurator[1]);
}
+ /**
+ * @group legacy
+ */
public function testType()
{
$container = new ContainerBuilder();
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
index 19f11d6fce0d4..fedea7084e4f9 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
@@ -325,6 +325,9 @@ public function testTypeNotString()
$loader->load('bad_types2.yml');
}
+ /**
+ * @group legacy
+ */
public function testTypes()
{
$container = new ContainerBuilder();