All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- Add support for
CollectionInterface::reduce()
(#87) - All exceptions now implement a base
CollectionException
interface - Introduce
Sort
enum - Support
column()
,sort()
, andwhere()
on non-object collection types
- Minimum PHP version supported is 8.1
- Every method now has parameter and return type hints; if extending classes or implementing interfaces, you may need to change method signatures to upgrade
- The second parameter of
CollectionInterface::sort()
now uses the newSort
enum instead of a string - Audit all template annotations and clean up Psalm and PHPStan types for correctness; if using static analysis in projects, this may require changes to your type annotations
ArrayInterface
no longer extends\Serializable
, and theserialize()
andunserialize()
methods have been removed fromAbstractArray
; however,AbstractArray
still supports serialization through implementing__serialize()
and__unserialize()
- Make type aliases compatible in diff, intersect, and merge (#111)
- Use
offsetUnset()
method to remove from the collection inAbstractCollection
(#104) - Use the correct base type of
array-key
for templateK
onAbstractTypedMap
- Minimum PHP version supported is 7.4
- Merging of sets now excludes duplicates, since a set does not allow duplicate values.
- Standardize template annotations and fix iterable types
- Support PHP 8.1.0
- Minimum PHP version supported is 7.3
- Add
Traversable<T>
return type togetIterator()
.
- Fixed incorrect callable type annotation on
CollectionInterface::map()
.
- Fixed Psalm annotations causing Psalm errors in downstream projects.
- Fixed
AbstractCollection::column()
attempting to access a property or method on a non-object.
- Fixed broken
AbstractCollection::map()
implementation.
- Fixed
AbstractCollection::diff()
,AbstractCollection::intersect()
andAbstractCollection::merge()
when used with Generic collections. - Fixed
AbstractCollection::diff()
andAbstractCollection::intersect()
returning inconsistent results when used on collections containing objects. - Removed warning about deprecated dependency when running
composer install
- Fixed
AbstractCollection::offsetSet()
so that it uses the provided$offset
when setting$value
in the array.
- Added support for queue data structures to represent collections of ordered
entities. Together with double-ended queues (a.k.a. deques),
first-in-first-out (FIFO), last-in-first-out (LIFO), and other queue and stack
behaviors may be implemented. This functionality includes interfaces
QueueInterface
andDoubleEndedQueueInterface
and classesQueue
andDoubleEndedQueue
. - Added support for set data structures, representing collections that cannot
contain any duplicated elements; includes classes
AbstractSet
andSet
. - Added support for typed map data structures to represent maps of elements
where both keys and values have specified data types; includes
TypedMapInterface
and the classesAbstractTypedMap
andTypedMap
. - Added new manipulation and analyze methods for collections:
column()
,first()
,last()
,sort()
,filter()
,where()
,map()
,diff()
,intersect()
, andmerge()
. See CollectionInterface for more information. - Added the following new exceptions specific to the ramsey/collection library:
CollectionMismatchException
,InvalidArgumentException
,InvalidSortOrderException
,NoSuchElementException
,OutOfBoundsException
,UnsupportedOperationException
, andValueExtractionException
.
- Minimum PHP version supported is 7.2.
- Strict types are enforced throughout.
- Removed support for HHVM.
- Fixed possible exploit using
AbstractArray::unserialize()
(see #47).
- Added
MapInterface::keys()
method to return the keys from aMapInterface
object. This was added to theAbstractMap
class.
- Removed
getType()
and constructor methods fromAbstractCollection
. Children ofAbstractCollection
must now implementgetType()
, which should return a string value that defines the data type of items for the collection.
- Improve error messages in exceptions when
Collection
andNamedParameterMap
items fail type checks.
- Allow non-strict checking of values in typed collections.
- Support typed collections.
- Support generic arrays and maps.