-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Description
Symfony (including 6.2) supports the @required annotation, see for example with Symfony 5.4: https://symfony.com/doc/5.4/service_container/autowiring.html
Tests have to cover a wide range of different cases:
symfony/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php
Line 244 in bc5fea4
| /** @inheritdoc*/ // <- brackets are missing on purpose |
symfony/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php
Line 312 in bc5fea4
| /** @required <tab> prefix is on purpose */ |
The proposal is to deprecate the @required annotation and suggest to replace it with Symfony\Contracts\Service\Attribute\Required.
This would simplify the codebase of Symfony at the next major release and encourage users to migrate from annotations to attributes.
See also:
- [DependencyInjection] 6.0 [autowiring] remove mention to @required symfony-docs#17654
- [DependencyInjection] 6.0 [injection_types] remove mention of @required in service_container symfony-docs#17655
- [FrameworkBundle] remove double required annotation + attribute #48874
Example
- /**
- @required
- /
+ #[\Symfony\Contracts\Service\Attribute\Required]