Skip to content

[ProxyManager] Support final classes #20392

@theofidry

Description

@theofidry

A service may be declared as final. In that situation, when the service is registered as lazy to Symfony DIC, it will throw an exception:

[ProxyManager\Exception\InvalidProxiedClassException] Provided class "Foo" is final and cannot be proxied

Where actually it can be proxied: you just need to proxy the parent class or the implemented interface instead like done in Zend\ServiceManager. I'm not sure how you are supposed to do however when your class extend another one and/or implements one or several interfaces. But the alternatives are:

  • Create a non-final decorator and use it instead
  • Remove the final keyword (not always doable)

TBH I think those two alternative solutions kind of sucks as I don't think the usage of a DIC should influence how you design you services.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions