Skip to content

Loading…

DCOM-189: Doctrine Proxies may conflict with interfaced constructors #490

Open
doctrinebot opened this Issue · 9 comments

2 participants

@doctrinebot

Jira issue originally created by user harmenm:

The Doctrine ProxyGenerator generates for a proxy a constructor. The documentation of Doctrine states that the constructor is never called. For a project, I created a group of entities with a interfaced constructor in order to enforce a common interface. This results in a incompatible proxy and so a fatal error.

@doctrinebot

Comment created by @ocramius:

Cannot fix this - the constructor is required to override instantiation logic

@doctrinebot

Comment created by harmenm:

Edit: added the correct description. I accidentially submitted the form before editing the description.

@doctrinebot

Comment created by @ocramius:

[~harmenm] why do you have a constructor in an interface? That's a very bad practice, and it makes things quite hard to handle.

I can think of a workaround, but I first want to be sure there's a real advantage in changing the current implementation to use unserialize() just to handle this specific use case.

@doctrinebot

Comment created by @beberlei:

Adding **construct to an interface is an anti pattern and shouldn't be done.

@doctrinebot

Comment created by harmenm:

Ok, then I change my implementation.

But, maybe it is an idea to update the documentation of the ORM and state that constructor interfacing is not possible?
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/architecture.html

@doctrinebot

Comment created by @ocramius:

I actually had more requests for this feature on a similar project ( Ocramius/ProxyManager#115 ).
I will mark this as feature request, but can't guarantee that it will get into Doctrine 2.x, since it may be a BC break.

@doctrinebot

Comment created by @guilhermeblanco:

Creating interfaces with **construct ties your contract preventing extensibility points. This is nature of OOP and I do not consider this should be documented because it's (in-theory) expected that people have some level of knowledge in OO design when coding.

Closing this as invalid.

@doctrinebot

Comment created by @ocramius:

Re-opening.

While interfaced constructors are a known bad practice, changing constructor parameters is also a well known LSP violation (a minor one).

I'll keep tracking this, but I'm blocked by HHVM's missing Closure::bind() as of facebook/hhvm#1203

@doctrinebot

Comment created by @ocramius:

Note: won't be solved in 2.5.0.

As a side-note, this was solved in ProxyManager meanwhile, but we can consider this change only for 3.0.x

@Ocramius Ocramius was assigned by doctrinebot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.