ramsey/collection
A PHP library for representing and manipulating collections.
2.1.1
557M downloads/mo
#56 most downloaded on composer
ramsey/collection
What this package is like to depend on
Last release 1 years ago
22 Mar 2025
Release timing varies
gaps range from 3 weeks to 2.6 years
Nearly every release is documented
notes for 18 of 18 stable releases
Nothing withdrawn
no release was ever pulled
11 years old
18 releases · first in 2015
0 releases in the last 12 months
see the full history below
Release timeline
18 releases · Oct 2015 to Mar 2025
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
Releases
latest 18-
2.1.122 Mar 2025Release notes
Open source →Fixed
- Correct the type annotation on
CollectionInterface::column()to indicate the array it returns islist<mixed>(#130)
Release notes
Open source →Fixed
- Correct the type annotation on
CollectionInterface::column()to indicate the array it returns islist<mixed>(#130)
- Correct the type annotation on
-
2.1.002 Mar 2025Release notes
Open source →Added
- Add support for retrieving properties on collection items that are accessible via magic methods
__getand__isset(#126) - Certify support for PHP 8.3 and 8.4 (#127)
Fixed
- Use the correct return type annotation of
list<T>instead ofarray<int, mixed>forCollectionInterface::column()(#124) - If an element has a property and method of the same name, check the property visibility on the element before attempting to access it; if it is private, attempt to call the method instead (#123)
ValueExtractorTraitexpectsgetType(): stringto exist on the using class, but it did not declare an abstract to force this requirement; now it does, and any classes using this trait must implementgetType(): string- Avoid calling
contains()twice when usingAbstractSet::add(), significantly improving performance for very large collections (#68)
Release notes
Open source →Added
- Add support for retrieving properties on collection items that are accessible via
magic methods
__getand__isset(#126) - Certify support for PHP 8.3 and 8.4 (#127)
Fixed
- Use the correct return type annotation of
list<T>instead ofarray<int, mixed>forCollectionInterface::column()(#124) - If an element has a property and method of the same name, check the property visibility on the element before attempting to access it; if it is private, attempt to call the method instead (#123)
ValueExtractorTraitexpectsgetType(): stringto exist on the using class, but it did not declare an abstract to force this requirement; now it does, and any classes using this trait must implementgetType(): string- Avoid calling
contains()twice when usingAbstractSet::add(), significantly improving performance for very large collections (#68)
- Add support for retrieving properties on collection items that are accessible via magic methods
-
2.0.031 Dec 2022Release notes
Open source →Added
- Add support for
CollectionInterface::reduce()(#87) - All exceptions now implement a base
CollectionExceptioninterface - Introduce
Sortenum - Support
column(),sort(), andwhere()on non-object collection types
Changed
- 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 newSortenum 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
ArrayInterfaceno longer extends\Serializable, and theserialize()andunserialize()methods have been removed fromAbstractArray; however,AbstractArraystill supports serialization through implementing__serialize()and__unserialize()
Release notes
Open source →Added
- Add support for
CollectionInterface::reduce()(#87) - All exceptions now implement a base
CollectionExceptioninterface - Introduce
Sortenum - Support
column(),sort(), andwhere()on non-object collection types
Changed
- 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 newSortenum 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
ArrayInterfaceno longer extends\Serializable, and theserialize()andunserialize()methods have been removed fromAbstractArray; however,AbstractArraystill supports serialization through implementing__serialize()and__unserialize()
- Add support for
-
1.3.027 Dec 2022Release notes
Open source →Fixed
- 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-keyfor templateKonAbstractTypedMap
Changed
- Minimum PHP version supported is 7.4
Release notes
Open source →Fixed
- 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-keyfor templateKonAbstractTypedMap
Changed
- Minimum PHP version supported is 7.4
-
1.2.210 Oct 2021Release notes
Open source →Fixed
- Merging of sets now excludes duplicates, since a set does not allow duplicate values.
Release notes
Open source →Fixed
- Merging of sets now excludes duplicates, since a set does not allow duplicate values.
-
1.2.106 Aug 2021 -
1.2.005 Aug 2021 -
1.1.430 Jul 2021Release notes
Open source →Fixed
- Fixed incorrect callable type annotation on
CollectionInterface::map().
- Fixed incorrect callable type annotation on
-
1.1.321 Jan 2021Release notes
Open source →Fixed
- Fixed incorrect callable type annotation on
CollectionInterface::map().
Release notes
Open source →Fixed
- Fixed incorrect callable type annotation on
CollectionInterface::map().
- Fixed incorrect callable type annotation on
-
1.1.221 Jan 2021Release notes
Open source →Fixed
- Fixed Psalm annotations causing Psalm errors in downstream projects.
- Fixed
AbstractCollection::column()attempting to access a property or method on a non-object.
Release notes
Open source →Fixed
- Fixed Psalm annotations causing Psalm errors in downstream projects.
- Fixed
AbstractCollection::column()attempting to access a property or method on a non-object.
-
1.1.110 Sep 2020 -
1.1.011 Aug 2020Release notes
Open source →Fixed
- 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
-
1.0.105 Jan 2020Release notes
Open source →Fixed
- Fixed
AbstractCollection::offsetSet()so that it uses the provided$offsetwhen setting$valuein the array.
- Fixed
-
1.0.031 Dec 2018Release notes
Open source →Added
- 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
QueueInterfaceandDoubleEndedQueueInterfaceand classesQueueandDoubleEndedQueue. - Added support for set data structures, representing collections that cannot
contain any duplicated elements; includes classes
AbstractSetandSet. - Added support for typed map data structures to represent maps of elements
where both keys and values have specified data types; includes
TypedMapInterfaceand the classesAbstractTypedMapandTypedMap. - 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.
Changed
- Minimum PHP version supported is 7.2.
- Strict types are enforced throughout.
Removed
- Removed support for HHVM.
Security
- Fixed possible exploit using
AbstractArray::unserialize()(see #47).
- 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
-
0.3.023 May 2016Release notes
Open source →Added
- Added
MapInterface::keys()method to return the keys from aMapInterfaceobject. This was added to theAbstractMapclass.
Removed
- Removed
getType()and constructor methods fromAbstractCollection. Children ofAbstractCollectionmust now implementgetType(), which should return a string value that defines the data type of items for the collection.
Fixed
- Improve error messages in exceptions when
CollectionandNamedParameterMapitems fail type checks.
- Added
-
0.2.122 Feb 2016 -
0.2.005 Feb 2016 -
0.1.027 Oct 2015