PackageTrack
Sign in Get early access

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
Release Pre-release

Releases

latest 18
  1. 2.1.1 22 Mar 2025
    Release notes

    Fixed

    • Correct the type annotation on CollectionInterface::column() to indicate the array it returns is list<mixed> (#130)
    Open source →
    Release notes

    Fixed

    • Correct the type annotation on CollectionInterface::column() to indicate the array it returns is list<mixed> (#130)
    Open source →
  2. 2.1.0 02 Mar 2025
    Release notes

    Added

    • Add support for retrieving properties on collection items that are accessible via magic methods __get and __isset (#126)
    • Certify support for PHP 8.3 and 8.4 (#127)

    Fixed

    • Use the correct return type annotation of list<T> instead of array<int, mixed> for CollectionInterface::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)
    • ValueExtractorTrait expects getType(): string to 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 implement getType(): string
    • Avoid calling contains() twice when using AbstractSet::add(), significantly improving performance for very large collections (#68)
    Open source →
    Release notes

    Added

    • Add support for retrieving properties on collection items that are accessible via magic methods __get and __isset (#126)
    • Certify support for PHP 8.3 and 8.4 (#127)

    Fixed

    • Use the correct return type annotation of list<T> instead of array<int, mixed> for CollectionInterface::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)
    • ValueExtractorTrait expects getType(): string to 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 implement getType(): string
    • Avoid calling contains() twice when using AbstractSet::add(), significantly improving performance for very large collections (#68)
    Open source →
  3. 2.0.0 31 Dec 2022
    Release notes

    Added

    • Add support for CollectionInterface::reduce() (#87)
    • All exceptions now implement a base CollectionException interface
    • Introduce Sort enum
    • Support column(), sort(), and where() 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 new Sort 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 the serialize() and unserialize() methods have been removed from AbstractArray; however, AbstractArray still supports serialization through implementing __serialize() and __unserialize()
    Open source →
    Release notes

    Added

    • Add support for CollectionInterface::reduce() (#87)
    • All exceptions now implement a base CollectionException interface
    • Introduce Sort enum
    • Support column(), sort(), and where() 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 new Sort 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 the serialize() and unserialize() methods have been removed from AbstractArray; however, AbstractArray still supports serialization through implementing __serialize() and __unserialize()
    Open source →
  4. 1.3.0 27 Dec 2022
    Release notes

    Fixed

    • Make type aliases compatible in diff, intersect, and merge (#111)
    • Use offsetUnset() method to remove from the collection in AbstractCollection (#104)
    • Use the correct base type of array-key for template K on AbstractTypedMap

    Changed

    • Minimum PHP version supported is 7.4
    Open source →
    Release notes

    Fixed

    • Make type aliases compatible in diff, intersect, and merge (#111)
    • Use offsetUnset() method to remove from the collection in AbstractCollection (#104)
    • Use the correct base type of array-key for template K on AbstractTypedMap

    Changed

    • Minimum PHP version supported is 7.4
    Open source →
  5. 1.2.2 10 Oct 2021
    Release notes

    Fixed

    • Merging of sets now excludes duplicates, since a set does not allow duplicate values.
    Open source →
    Release notes

    Fixed

    • Merging of sets now excludes duplicates, since a set does not allow duplicate values.
    Open source →
  6. 1.2.1 06 Aug 2021
    Release notes

    Fixed

    • Standardize template annotations and fix iterable types
    Open source →
    Release notes

    Fixed

    • Standardize template annotations and fix iterable types
    Open source →
  7. 1.2.0 05 Aug 2021
    Release notes

    Added

    • Support PHP 8.1.0

    Changed

    • Minimum PHP version supported is 7.3
    Open source →
    Release notes

    Added

    • Support PHP 8.1.0

    Changed

    • Minimum PHP version supported is 7.3
    Open source →
  8. 1.1.4 30 Jul 2021
    Release notes

    Fixed

    • Fixed incorrect callable type annotation on CollectionInterface::map().
    Open source →
    Release notes

    Fixed

    • Add Traversable<T> return type to getIterator().
    Open source →
  9. 1.1.3 21 Jan 2021
    Release notes

    Fixed

    • Fixed incorrect callable type annotation on CollectionInterface::map().
    Open source →
    Release notes

    Fixed

    • Fixed incorrect callable type annotation on CollectionInterface::map().
    Open source →
  10. 1.1.2 21 Jan 2021
    Release notes

    Fixed

    • Fixed Psalm annotations causing Psalm errors in downstream projects.
    • Fixed AbstractCollection::column() attempting to access a property or method on a non-object.
    Open source →
    Release notes

    Fixed

    • Fixed Psalm annotations causing Psalm errors in downstream projects.
    • Fixed AbstractCollection::column() attempting to access a property or method on a non-object.
    Open source →
  11. 1.1.1 10 Sep 2020
    Release notes

    Fixed

    • Fixed broken AbstractCollection::map() implementation.
    Open source →
  12. 1.1.0 11 Aug 2020
    Release notes

    Fixed

    • Fixed AbstractCollection::diff(), AbstractCollection::intersect() and AbstractCollection::merge() when used with Generic collections.
    • Fixed AbstractCollection::diff() and AbstractCollection::intersect() returning inconsistent results when used on collections containing objects.
    • Removed warning about deprecated dependency when running composer install
    Open source →
  13. 1.0.1 05 Jan 2020
    Release notes

    Fixed

    • Fixed AbstractCollection::offsetSet() so that it uses the provided $offset when setting $value in the array.
    Open source →
  14. 1.0.0 31 Dec 2018
    Release notes

    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 QueueInterface and DoubleEndedQueueInterface and classes Queue and DoubleEndedQueue.
    • Added support for set data structures, representing collections that cannot contain any duplicated elements; includes classes AbstractSet and Set.
    • 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 classes AbstractTypedMap and TypedMap.
    • Added new manipulation and analyze methods for collections: column(), first(), last(), sort(), filter(), where(), map(), diff(), intersect(), and merge(). See CollectionInterface for more information.
    • Added the following new exceptions specific to the ramsey/collection library: CollectionMismatchException, InvalidArgumentException, InvalidSortOrderException, NoSuchElementException, OutOfBoundsException, UnsupportedOperationException, and ValueExtractionException.

    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).
    Open source →
  15. 0.3.0 23 May 2016
    Release notes

    Added

    • Added MapInterface::keys() method to return the keys from a MapInterface object. This was added to the AbstractMap class.

    Removed

    • Removed getType() and constructor methods from AbstractCollection. Children of AbstractCollection must now implement getType(), which should return a string value that defines the data type of items for the collection.

    Fixed

    • Improve error messages in exceptions when Collection and NamedParameterMap items fail type checks.
    Open source →
  16. 0.2.1 22 Feb 2016
    Release notes

    Fixed

    • Allow non-strict checking of values in typed collections.
    Open source →
  17. 0.2.0 05 Feb 2016
    Release notes

    Added

    • Support typed collections.
    Open source →
  18. 0.1.0 27 Oct 2015
    Release notes

    Added

    • Support generic arrays and maps.
    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive