Skip to content

Deprecation when using @ParamConverter and Type Hints since Symfony 3.4 #24891

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
iluuu1994 opened this issue Nov 9, 2017 · 7 comments
Closed

Comments

@iluuu1994
Copy link
Contributor

iluuu1994 commented Nov 9, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4.0-BETA3

I get the following deprecation message:

Relying on service auto-registration for type "MyEntity" is deprecated since version 3.4 and won't be supported in 4.0. Create a service named "MyEntity" instead.

This is my action:

/**
 * @Route("/my-entity/{id}")
 * @ParamConverter("myEntity", options={"id"="id"})
 */
public function editMyEntityAction(Request $request, MyEntity $myEntity)
{
    // ...
}

The deprecation goes away as soon as I remove the MyEntity type hint. It looks like Symfony thinks I'm trying to inject a MyEntity service. Is this a bug or am I doing something wrong?

Thanks!

@ogizanagi
Copy link
Contributor

Hi @iluuu1994.
This is bad pre-sf 3.3 autowiring happening. Try setting the container.autowiring.strict_mode parameter to true in your application in order to disable the BC layer.

Some refs about this:

@iluuu1994
Copy link
Contributor Author

@ogizanagi And sure enough, the deprecations are gone!

Sorry, I wasn't aware of that. Thank you!

@Taluu
Copy link
Contributor

Taluu commented Nov 14, 2017

This is still a bug IMO...

@ogizanagi
Copy link
Contributor

@Taluu : Not really to me. It's an incompatibility between the old autowiring system and the ServiceValueResolver introduced in 3.3, which is only opt-in by using the controller.service_arguments tag on the controller, while the first one is deprecated and opt-out thanks to the mentioned param.

@kironet
Copy link

kironet commented Dec 22, 2017

Ok, what will happen if you upgrade to 4.0?
It will broke a project right? Because this parameter is useless on 4.0(as I read somewhere)..?

@iluuu1994
Copy link
Contributor Author

@kironet No. This flag disables the compatibility mode which is not present in Symfony 4.0. Thus this error will not occur in Symfony 4.0 projects.

@givihuda
Copy link

Not quite sure I'm understanding... you say "this error will not occur in Symfony 4.0 projects", as in that deprecation warning? I think we already know that because deprecation warnings from Symfony 3.4 go away in 4.0 because they're literally removed. What will happen if we don't fix the deprecation warnings is that Symfony 4.0 will break but with a new error (or maybe no error)... so I think what kironet is asking is if setting container.autowiring.strict_mode parameter to true simply hides a warning that will become a problem in 4.0, and I can't tell if you're saying that that's not true.

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

No branches or pull requests

5 participants