[PR #677] Type fix in ORM\PersistentCollection #8545

Closed
opened 2026-01-22 16:00:24 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/677

State: closed
Merged: No


The ORM\PersistentCollection class accepts anything as 3rd argument to its constructor while it should be either array or Collection object. The $this->coll phpdoc says that it's a Collection while the constructor's phpdoc says it's an array.

The class assumes Collection but there isn't any type check at all. I have added conversion of array into ArrayCollection in the constructor as in some (very unclear) cases it likes to die with a fatal error:

Fatal error: Call to a member function add() on a non-object in Doctrine/ORM/PersistentCollection.php on line 169

**Original Pull Request:** https://github.com/doctrine/orm/pull/677 **State:** closed **Merged:** No --- The `ORM\PersistentCollection` class accepts anything as 3rd argument to its constructor while it should be either array or `Collection` object. The `$this->coll` phpdoc says that it's a `Collection` while the constructor's phpdoc says it's an array. The class assumes `Collection` but there isn't any type check at all. I have added conversion of array into `ArrayCollection` in the constructor as in some (very unclear) cases it likes to die with a fatal error: `Fatal error: Call to a member function add() on a non-object in Doctrine/ORM/PersistentCollection.php on line 169`
admin added the pull-request label 2026-01-22 16:00:24 +01:00
admin closed this issue 2026-01-22 16:00:24 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#8545