DDC-266: Example for removing objects by value from a collection is wrong or ambiguous #330

Closed
opened 2026-01-22 12:35:02 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 22, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user bmills:

Under the section about removing associated objects from a collection (Working With Objects), there should be special mention made to distinguish between the remove($key) and removeElement($element) methods in ArrayCollection.

The current example is ambiguous and may indicate that elements (objects) can be removed via the remove() method:

// Article <- one-to-many -> Comment
$article->getComments()->remove($comment);

Passing an object instead of a key into remove() causes a fatal error. Using removeElement($comment) in the example would make more sense.

Thanks!

Originally created by @doctrinebot on GitHub (Jan 22, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user bmills: Under the section about removing associated objects from a collection (Working With Objects), there should be special mention made to distinguish between the remove($key) and removeElement($element) methods in ArrayCollection. The current example is ambiguous and may indicate that elements (objects) can be removed via the remove() method: // Article <- one-to-many -> Comment $article->getComments()->remove($comment); Passing an object instead of a key into remove() causes a fatal error. Using removeElement($comment) in the example would make more sense. Thanks!
admin added the Bug label 2026-01-22 12:35:02 +01:00
admin closed this issue 2026-01-22 12:35:02 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 7, 2010):

Comment created by @beberlei:

Fixed

@doctrinebot commented on GitHub (Feb 7, 2010): Comment created by @beberlei: Fixed
Author
Owner

@doctrinebot commented on GitHub (Feb 7, 2010):

Issue was closed with resolution "Fixed"

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

No dependencies set.

Reference: doctrine/archived-orm#330