Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Contracts] Rename ServiceSubscriberTrait to ServiceMethodsSubscriberTrait #54496

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

Merged

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Apr 5, 2024

Q A
Branch? 7.1
Bug fix? no
New feature? no
Deprecations? yes
Issues Fix #54490
License MIT

As 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

@carsonbot carsonbot added this to the 7.1 milestone Apr 5, 2024
@nicolas-grekas nicolas-grekas changed the title [Contracts] Rename ServiceSubscriberTrait to ServiceMethodsSubscriber… [Contracts] Rename ServiceSubscriberTrait to ServiceMethodsSubscriberTrait Apr 5, 2024
@nicolas-grekas nicolas-grekas force-pushed the service-methods-subscriber-trait branch from 7f17197 to caaa488 Compare April 5, 2024 09:30
@nicolas-grekas nicolas-grekas force-pushed the service-methods-subscriber-trait branch from caaa488 to 8f47ced Compare April 5, 2024 09:39
@fabpot
Copy link
Member

fabpot commented Apr 5, 2024

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 26d71d3 into symfony:7.1 Apr 5, 2024
6 of 10 checks passed
@nicolas-grekas nicolas-grekas deleted the service-methods-subscriber-trait branch April 5, 2024 11:37
@MatTheCat
Copy link
Contributor

This PR seems to break the Unit Tests (8.2, low-deps) job: https://github.com/symfony/symfony/actions/runs/8567827866/job/23480399192#step:8:239

@xabbuh
Copy link
Member

xabbuh commented Apr 9, 2024

@MatTheCat fixed now after the sub-tree split for the service contracts was synchronised

javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Apr 10, 2024
…ated and replaced by `ServiceMethodsSubscriberTrait` (GromNaN)

This PR was merged into the 7.1 branch.

Discussion
----------

[DependencyInjection] `ServiceSubscriberTrait` is deprecated and replaced by `ServiceMethodsSubscriberTrait`

Fix #19755
Related code change: symfony/symfony#54496

Commits
-------

f17331c ServiceSubscriberTrait is deprecated and replaced by ServiceMethodsSubscriberTrait
@fabpot fabpot mentioned this pull request May 2, 2024
xabbuh added a commit that referenced this pull request Oct 10, 2024
This PR was merged into the 7.1 branch.

Discussion
----------

[Contracts] add missing properties

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

Since #54496 the property is no longer part of the `ServiceSubscriberTrait` triggering a PHP deprecation like:

> Creation of dynamic property Symfony\Contracts\Tests\Service\LegacyTestService::$container is deprecated

Commits
-------

fbfeefe add missing properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants