Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Make ServiceSubscriberTrait compatible with AbstractController for Symfony 7 with strong types#54490
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
derrabus commentedApr 4, 2024
Your change would be a breaking change for other users of the trait. I'm afraid, we cannot merge it. |
pableu commentedApr 4, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I see. Can we.. tag a higher version maybe? How is versioning and the bc-promise done for symfony/contracts? My issue appeared when upgrading from 6.4 to 7.0. I can easily work around it, but I thought an easier upgrade and more type safety in the trait might be nice. |
nicolas-grekas commentedApr 5, 2024
That's quite unfortunate! |
pableu commentedApr 5, 2024
Oh lovely@nicolas-grekas, thanks for your much more complete solution in#54496, that looks great. |
…thodsSubscriberTrait (nicolas-grekas)This PR was merged into the 7.1 branch.Discussion----------[Contracts] Rename ServiceSubscriberTrait to ServiceMethodsSubscriberTrait| Q | A| ------------- | ---| Branch? | 7.1| Bug fix? | no| New feature? | no| Deprecations? | yes| Issues |Fix#54490| License | MITAs described in the linked PR, AbstractController is incompatible with ServiceSubscriberTrait because of the added type to the AbstractController::$container property, while ServiceSubscriberTrait's $container property cannot have a type without a BC break.There are two parts to this PR:- Deprecate ServiceSubscriberTrait in favor if ServiceMethodsSubscriberTrait, which declares the type of the $container property. The new name better conveys its purpose as a bonus.- Fix the incompatibility with AbstractController by removing the property declaration on ServiceSubscriberTrait. This means the trait will create a dynamic property. Those are deprecated, but since the trait is also deprecated, the upgrade path is clear.I also tried to improve the description of the trait in the meantime./cc `@kbond`Commits-------8f47ced [Contracts] Rename ServiceSubscriberTrait to ServiceMethodsSubscriberTrait
If you have a class like this:
You get the following error in Symfony 7 with symfony/contracts 3.4.2:
ServiceSubscriberTrait::$containeris defined as:While
AbstractController::$containeris:This leads to the incompatible composition.
This PR would fix that, but I'm not sure which versions of symfony/framework-bundle and symfony/contracts to target. Maybe we should add a conflict against symfony/framework-bundle < 7.0 to symfony/contract's
composer.json.