DDC-2796: [GH-847] Removed final from PersistentCollection #3500

Closed
opened 2026-01-22 14:21:08 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 15, 2013).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of maryo:

Url: https://github.com/doctrine/doctrine2/pull/847

Message:

I would like to be able to extend PersistentCollection. But it is final.

There is "@todo Design for inheritance to allow custom implementations?" in PersistentCollection.php.

Ofc it needs more modifications because the instantiation of PersistentCollections is hardcoded in UnitOfWork and ObjectHydrator classes. Creating something like PersistentCollectionFactory or persistentCollectionClass could solve it but there are already lots of dependencies in those classes. I can live with the hardoded state. I can somehow "hack" it so it will always replace PersistentCollection instances with my own which extends PersistentCollection when they are set. It's ugly but it could work..

So... At least removing the final statement helps me and could be a good start. Switching from private to protected for $em and $coll helps me also so i can read them in the descendant class but it can be "hacked" too even if i don't like hacks).

If you can't accept this PR, let me know about the idea how "@todo Design for inheritance to allow custom implementations?" could be implemented and i will do it. If using a factory, class name or whatever.

Originally created by @doctrinebot on GitHub (Nov 15, 2013). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of maryo: Url: https://github.com/doctrine/doctrine2/pull/847 Message: I would like to be able to extend PersistentCollection. But it is final. There is "@todo Design for inheritance to allow custom implementations?" in PersistentCollection.php. Ofc it needs more modifications because the instantiation of PersistentCollections is hardcoded in UnitOfWork and ObjectHydrator classes. Creating something like PersistentCollectionFactory or persistentCollectionClass could solve it but there are already lots of dependencies in those classes. I can live with the hardoded state. I can somehow "hack" it so it will always replace PersistentCollection instances with my own which extends PersistentCollection when they are set. It's ugly but it could work.. So... At least removing the final statement helps me and could be a good start. Switching from private to protected for $em and $coll helps me also so i can read them in the descendant class but it can be "hacked" too even if i don't like hacks). If you can't accept this PR, let me know about the idea how "@todo Design for inheritance to allow custom implementations?" could be implemented and i will do it. If using a factory, class name or whatever.
admin added the Bug label 2026-01-22 14:21:08 +01:00
admin closed this issue 2026-01-22 14:21:08 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 2, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-847] was closed:
https://github.com/doctrine/doctrine2/pull/847

@doctrinebot commented on GitHub (Jan 2, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-847] was closed: https://github.com/doctrine/doctrine2/pull/847
Author
Owner

@doctrinebot commented on GitHub (Jan 2, 2014):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Jan 2, 2014): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3500