This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/Tests/Fixtures
Fabien Potencier 3c9a591c06 feature #22903 [DI] Deprecate XML services without ID (ro0NL)
This PR was merged into the 3.4 branch.

Discussion
----------

[DI] Deprecate XML services without ID

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no, confusing though
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

On slack someone had a issue with class named services;

> So, probably should have done this sooner, I stepped through with a debugger and it looks like \Symfony\Component\DependencyInjection\Loader\XmlFileLoader::processAnonymousServices assigns a sha256 to services that don't have any IDs
> When my manually wired service is registered, it has an ID that looks like 1_344b468f6069ffe8c32092409d99c59abc218f41071ce4c4230c198876129bc0, so it doesn't override the auto-loaded one
> I swear I read that IDs default to the class name now...

The fix was easy; doing `<service id="ClassName"/>` instead of `<service class="ClassName"/>`. However the thing is... i made the exact same mistake trying to reproduce 😅

I think given the recent developments (dropping type based autowiring and class named services) it makes sense to force XML service to specify an ID attribute (the top level ones). This would be consistent with YAML and PHP as well.

Fixing deprecations is also easy, just change `class` attribute to `id` like i've done for the frameworkbundle in this PR.

Any thoughts?

Commits
-------

b8c68da010 [DI] Deprecate XML services without ID
2017-05-25 16:22:40 -07:00
..
containers Merge branch '3.2' into 3.3 2017-05-25 16:10:31 -07:00
directory [DI][Routing] recursive directory loading 2015-06-02 16:17:59 -07:00
graphviz [*Bundle] Add autowiring aliases for common services 2017-03-21 22:34:27 +01:00
includes [DI] prepare for signature change in 4.0 2017-05-24 13:31:33 +02:00
ini [DI] FileLoaders: Allow to explicit type to load 2017-01-10 12:54:54 +01:00
php [DependencyInjection] Fix dumping of RewindableGenerator with empty IteratorArgument 2017-05-19 23:56:58 +02:00
Prototype Allowing prototype/PSR4 service loading ability to exclude, because glob doesn't support this 2017-05-13 13:10:49 -04:00
xml feature #22903 [DI] Deprecate XML services without ID (ro0NL) 2017-05-25 16:22:40 -07:00
yaml [DependencyInjection] Fix dumping of RewindableGenerator with empty IteratorArgument 2017-05-19 23:56:58 +02:00
CaseSensitiveClass.php [DI] Add tests for class named services 2017-01-07 16:55:01 +01:00
CustomDefinition.php [DI] Fixed custom services definition BC break introduced in ec7e70fb… 2016-11-24 11:34:23 +01:00
DeprecatedClass.php [DI] Prevent AutowirePass from triggering irrelevant deprecations 2017-04-05 16:41:09 +02:00
FactoryDummy.php [DependencyInjection] Automatically detect the definitions class when possible 2016-07-31 12:30:18 +02:00
NamedArgumentsDummy.php Fixing bug where indexed args were set wrong in pass in some situations 2017-05-09 05:53:08 -04:00
StubbedTranslator.php [DI] Test references inside ServiceLocator are not inlined 2017-04-29 20:26:40 +02:00
TestServiceSubscriber.php [DI] Restrict autowired registration to "same-vendor" namespaces 2017-04-06 11:28:30 +02:00