diff --git a/UPGRADE-3.3.md b/UPGRADE-3.3.md
index 1269051076..0aa94f4af5 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 1ff703c8e9..22c732a22e 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 1bb51867da..0860132ad1 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
@@ -220,10 +220,9 @@ class JsonDescriptor extends Descriptor
'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 d7b48cef8d..c0319aad6b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
@@ -185,8 +185,8 @@ class MarkdownDescriptor extends Descriptor
."\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 8ccdef4fca..bb7a76ab0c 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
@@ -294,8 +294,9 @@ class TextDescriptor extends Descriptor
$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 4ef67a42b6..722a014373 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 @@ class TemplatingPass implements CompilerPassInterface
}
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 30be027e02..7eec06b7d4 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -1096,8 +1096,8 @@ class FrameworkExtension extends Extension
->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 a2a0fb4065..c0e5532381 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 1ebca5caf3..c4dfd51afe 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 75b77914bd..6cd41fb882 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 9efbde5a86..09260d6159 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 52d2520a87..75347e1a0e 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 9f89e47dc2..03b4f36e13 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 f386f4540e..dd639178f6 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 ff2db6858d..8678c9f2cc 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 170dfa2887..d970cbc06f 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 fe2b183901..ceb490e3f5 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 a25a34b44a..0b2ecdb584 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 25138d78fd..34b52ef6f1 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 d11d6e92d4..9be50bc4dc 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 f74cdbbccd..596d918579 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 8a6611a37c..bfc93101e7 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 cee9d8ff7d..512845c9ec 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 0fd51dcde9..7ac1ac0ff1 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 d6e39a5aa8..9d339b517e 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 a0f6e235de..7385e98f11 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 cee9d8ff7d..512845c9ec 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 e41bccbd85..c6ce00308f 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 de2d57a84d..83cb204822 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
@@ -245,6 +245,13 @@ class AutowirePass extends AbstractRecursivePass
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 @@ class AutowirePass extends AbstractRecursivePass
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 8edb717b4c..d1fe95a0bc 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php
@@ -53,11 +53,15 @@ class DecoratorServicePass implements CompilerPassInterface
} 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 eddecfeb4c..c21a58f6b7 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
@@ -53,9 +53,9 @@ class PassConfig
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 7839111539..7c9eac2881 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php
@@ -90,7 +90,9 @@ class ResolveDefinitionTemplatesPass extends AbstractRecursivePass
$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 @@ class ResolveDefinitionTemplatesPass extends AbstractRecursivePass
}
// 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 6329154b9e..66c48a355c 100644
--- a/src/Symfony/Component/DependencyInjection/Definition.php
+++ b/src/Symfony/Component/DependencyInjection/Definition.php
@@ -679,9 +679,13 @@ class Definition
* @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 @@ class Definition
* 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 @@ class Definition
* @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 @@ class Definition
* @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 @@ class Definition
* @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 03097e3d13..73fb33c2ae 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
@@ -201,7 +201,7 @@ class XmlDumper extends Dumper
$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 87a6024506..b0ab9d6a2c 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
@@ -107,7 +107,7 @@ class YamlDumper extends Dumper
}
$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 d1a596134b..e9a8c2fc68 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php
@@ -191,7 +191,7 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase
$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 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase
$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 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase
$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 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase
$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 fbdd3af372..9712ac474d 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php
@@ -143,6 +143,9 @@ class DecoratorServicePassTest extends \PHPUnit_Framework_TestCase
$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 1dc96e7396..28a8495227 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php
@@ -322,6 +322,9 @@ class ResolveDefinitionTemplatesPassTest extends \PHPUnit_Framework_TestCase
$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 ee6f42ea42..0fb736427c 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php
@@ -313,6 +313,9 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
$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 3e033059ae..cba10b526b 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 = new ContainerBuilder();
$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 476588aa4d..9f01ead067 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 1894077e4b..174bee32f8 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 4fcd667f57..45c6a87e86 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
@@ -554,6 +554,9 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$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 19f11d6fce..fedea7084e 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
@@ -325,6 +325,9 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
$loader->load('bad_types2.yml');
}
+ /**
+ * @group legacy
+ */
public function testTypes()
{
$container = new ContainerBuilder();