Skip to content
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

Lazy services - Final classes cannot be proxied by ProxyManager #690

Closed
vhejda opened this issue Oct 22, 2018 · 2 comments
Closed

Lazy services - Final classes cannot be proxied by ProxyManager #690

vhejda opened this issue Oct 22, 2018 · 2 comments
Labels

Comments

@vhejda
Copy link

vhejda commented Oct 22, 2018

I am testing the 3.0.0@RC in a Symfony 3.4 project, and after installing, I am getting:

PHP Fatal error:  Uncaught ProxyManager\Exception\InvalidProxiedClassException: 
Provided class "JMS\Serializer\Handler\FormErrorHandler" is final and cannot be proxied

It is coming from ocramius/proxy-manager, as the FormErrorHandler is a final class and the service is registered as lazy="true". ocramius/proxy-manager is a dev-dependency of symfony/symfony, so I suppose I will not be the only affected person.

Related issue on Symfony/Symfony suggest dropping the final keyword:
symfony/symfony#20392

This might be fixing the problem, but looks like it's only merged to Symfony 4.x:
symfony/symfony#27697

I'd be happy to give a hand here, but not sure what the solution in here should be. Dropping the final on the affected classes in jms/serializer, or dropping the lazy=true here in bundle? Or something else?

Thanks for looking into this!

@goetas goetas added the bug label Oct 22, 2018
@goetas
Copy link
Collaborator

goetas commented Oct 22, 2018

My preferred solution here is to remove lazy=true from the handlers.
But I'm curious about the performance difference...

@goetas
Copy link
Collaborator

goetas commented Oct 22, 2018

Curious to know if is worth keeping the final keyword in the classes...

The reason for adding the final keyword is that many devs were extending handlers and re implementating 100% of them. More than once inherentance introduced problems that without will not arise

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

No branches or pull requests

2 participants