8000 [DI] Replace autowiring BC break by regular deprecation by nicolas-grekas · Pull Request #22384 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DI] Replace autowiring BC break by regular deprecation #22384

New issue 8000

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
merged 1 commit into from
Apr 12, 2017

Conversation

nicolas-grekas
Copy link
Member
Q A
Branch? 3.3
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

It happens that doing so is really easy now. And as discussed in #22295, this should be more friendly to our users.

@nicolas-grekas nicolas-grekas added this to the 3.3 milestone Apr 11, 2017
@nicolas-grekas nicolas-grekas changed the title [DI] Repace autowiring BC break by regular deprecation [DI] Replace autowiring BC break by regular deprecation Apr 11, 2017
Copy link
Member
@stof stof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecating rather than breaking BC is always better

@kiler129
Copy link
Contributor

@nicolas-grekas: Big thumbs up for this change! BC promise and being open & flexible with changes are the most important reason for using Symfony in serious projects.

@fabpot
Copy link
Member
fabpot commented Apr 12, 2017

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 0ed087d into symfony:master Apr 12, 2017
fabpot added a commit that referenced this pull request Apr 12, 2017
…n (nicolas-grekas)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Replace autowiring BC break by regular deprecation

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

It happens that doing so is really easy now. And as discussed in #22295, this should be more friendly to our users.

Commits
-------

0ed087d [DI] Replace autowiring BC break by regular deprecation
@nicolas-grekas nicolas-grekas deleted the di-deprec-autow branch April 12, 2017 14:32
@fabpot fabpot mentioned this pull request May 1, 2017
@@ -291,6 +291,12 @@ private function getAutowiredReference(TypedReference $reference)
return new TypedReference($this->types[$type], $type);
}

if (isset($this->types[$type])) {
@trigger_error(sprintf('Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won\'t be supported in version 4.0. You should %s the "%s" service to "%s" instead.', isset($this->types[$this->types[$type]]) ? 'alias' : 'rename (or alias)', $this->types[$type], $type), E_USER_DEPRECATED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If somebody typehints an implementation instead of an interface, this deprecation is misleading. They do not need to change the services but also only change the typhint.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the case in createTypeAlternatives, see "or type-hint against etc."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but that only happens if no autowired service can be found. If it works with a by-type deprecation, the alternatives are not suggested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. if you typehint the serializer implementation instead of the interface

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.

6 participants
0