doctrine / doctrine/collections

RemoveElement return type nullable?

Open
#413 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
6k
Forks
187
PR merge metrics
No merged PRs in 30d

Description

Hello,
so here is issue in doctrine with LazyCollections https://github.com/doctrine/orm/issues/8739#issuecomment-1992240793
Long story short if collection is lazy and we call remove() ideally we don't want to load whole collection into memory.
This can be implemented but there is issue with return type of remove(). When calling it on lazy collection we don't know if element is within collection or not. Therefore cannot return bool true/false.
So ideally I'd change `Collection::removeElement : bool` to `Collection::removeElement : bool|null` with description that null is returned if removal cannot be confirmed (eg. lazy collection)
Does that make sense?

Contributor guide

Open the contributing guide

Research direction

Start by reading the Collection::removeElement declaration and the linked Doctrine ORM discussion. Determine how lazy collections are expected to report an unconfirmed removal and whether the public return-type contract can support that behavior. Done means the contract and affected implementations have an agreed, tested behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.