-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Lock] [Framework] Add private aliases with only name for LockFactory
services
#60874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 7.4
Are you sure you want to change the base?
[Lock] [Framework] Add private aliases with only name for LockFactory
services
#60874
Conversation
Valmonzo
commented
Jun 23, 2025
Q | A |
---|---|
Branch? | 7.4 |
Bug fix? | no |
New feature? | yes |
Deprecations? | no |
Issues | Fix #60349 |
License | MIT |
LockFactory
servicesLockFactory
services
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
LockFactory
servicesLockFactory
services
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workflow works because it has two lines:
$container->registerAliasForArgument($workflowId, WorkflowInterface::class, $name.'.'.$type);
$container->registerAliasForArgument($workflowId, WorkflowInterface::class, $name);
HttpClient/Cache work because they don't add any conventions: scoped clients' / cache pool names are their service names.
And there are other subsystems that create their own conventions:
$container->registerAliasForArgument($serializerId, SerializerInterface::class, $serializerName.'.serializer');
$container->registerAliasForArgument($serializerId, NormalizerInterface::class, $serializerName.'.normalizer');
$container->registerAliasForArgument($serializerId, DenormalizerInterface::class, $serializerName.'.denormalizer');
$container->registerAliasForArgument('assets._package_'.$name, PackageInterface::class, $name.'.package');
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', LockFactory::class, $resourceName.'.lock.factory');
$container->registerAliasForArgument('semaphore.'.$resourceName.'.factory', SemaphoreFactory::class, $resourceName.'.semaphore.factory');
$container->registerAliasForArgument($limiterId, RateLimiterFactoryInterface::class, $name.'.limiter');
Looks like they would all benefit from something similar, isn't it?
To improve the situation, we could add an argument, $target to registerAliasForArgument (using a proper BC layer). The implementation would just create this second alias we're considering to add here.
And we would also patch debug:autowiring so that it groups those two lines in one (see "target" entry in the output).
WDYT?
Is this something you might want to work on @Valmonzo?
@nicolas-grekas most cases are adding a suffix mostly because they were implemented at a time where named autowiring was based on argument names, where we would expect the argument name (and so often the property name) to end with When using the |
So let's start with adding all those aliases and call |
@nicolas-grekas given the maintenance cost of the double aliases is low, maybe we should make it easier to support multiple versions of Symfony by delaying the deprecation (you cannot use |
I like the fact that one can choose not to use the attribute as it’s less boilerplate for aliases that are used a lot. |
Same preference as @chalasr , but whatever you choose, I'll be happy to work on it ! |
@@ -3,7 +3,7 @@ CHANGELOG | |||
|
|||
7.4 | |||
--- | |||
|
|||
* Register alias for argument for lock services with lock name only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Register alias for argument for lock services with lock name only | |
* Register alias for argument for lock services with lock name only |