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

Skip to content

[DI] Service auto-registration error message still exists #25959

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

Closed
weaverryan opened this issue Jan 29, 2018 · 4 comments
Closed

[DI] Service auto-registration error message still exists #25959

weaverryan opened this issue Jan 29, 2018 · 4 comments

Comments

@weaverryan
Copy link
Member

weaverryan commented Jan 29, 2018

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4

Just a minor thing: in 4.0 (or 3.4 with strict mode on), we removed the "service auto-registration" functionality of autowiring (i.e. where autowiring would automatically register a service for you if non existed for a class). But, the error message and some related code still exists:

return ' It cannot be auto-registered because it is from a different root namespace.';

Unless I'm mistaken, this stuff should be removed in 4.0: the error message should not mention anything about auto-registration :). But, it's not as simple as just removing the if statement - in practice, the final error doesn't quite make sense.

To repeat the situation:

  1. Type-hint some vendor class (e.g. MyLib\FooClient that has a service in the container (e.g. my_lib.foo_client, but does not have an autowireable alias.

  2. The error will mention auto-registration. But if you simply remove the last elseif, the final message will also not make sense: it should suggest adding an alias from MyLib\FooClient to my_lib.foo_client.

@weaverryan weaverryan added this to the 4.0 milestone Jan 29, 2018
@weaverryan weaverryan added the Bug label Jan 29, 2018
@nicolas-grekas
Copy link
Member

The bug must also exist in 3.4, when strict mode is on.

@weaverryan weaverryan modified the milestones: 4.0, 3.4 Jan 29, 2018
@weaverryan
Copy link
Member Author

You're right - updated the PR and milestone accordingly.

@Tobion
Copy link
Contributor

Tobion commented Feb 12, 2018

Aren't there circumstances where autoregistration still happens? Like explained in #22295 (comment) and #22306
Or did that get deprecated in 3.4 again?

@weaverryan
Copy link
Member Author

@Tobion It eventually got totally deprecated in 3.4 and removed in 4.0. It's kinda nice: in 4.0 there is 0 auto-registration from autowiring

nicolas-grekas added a commit that referenced this issue Mar 22, 2018
… mode (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[DI] Dont tell about autoregistration in strict autowiring mode

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

Commits
-------

5e922db [DI] Dont tell about autoregistration in strict autowiring mode
nicolas-grekas added a commit that referenced this issue Mar 22, 2018
…kas)

This PR was merged into the 4.0 branch.

Discussion
----------

[DI] Cleanup remainings from autoregistration

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

Commits
-------

74afff8 [DI] Cleanup remainings from autoregistration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants