Add Collection::slice($offset, $length)

Details

Description

Since we are still at a point were bc breaks are potentially not so harming:

We need a slice() method on the Collection for forward compatibility, the support for large and very large collections using FETCH_EXTRA would heavily benefit from a method like this.

/**
* Extract a slice of $length elements starting at position $offset from the Collection.
*
* If $length is null it returns all elements from $offset to the end of the Collection.
* Keys have to be preserved by this method.
*
* @param int $offset
* @param int $length
* @return array
*/
public function slice($offset, $length = null);

Jan Pieper
added a comment - 14/Jan/11 5:39 AM Is there any reason why slice() returns an array although methods like filter() and map() return an instance of Doctrine\Common\Collections\ArrayCollection?