PHPackages                             eclipxe/generic-collections - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. eclipxe/generic-collections

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

eclipxe/generic-collections
===========================

Library to mimics generic collections

v0.3.0(9y ago)26.9kMITPHPPHP &gt;=5.6

Since Jun 3Pushed 9y ago2 watchersCompare

[ Source](https://github.com/eclipxe13/generic-collections)[ Packagist](https://packagist.org/packages/eclipxe/generic-collections)[ Docs](https://github.com/eclipxe13/generic-collections)[ RSS](/packages/eclipxe-generic-collections/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (5)Versions (6)Used By (0)

eclipxe/generic-collections
===========================

[](#eclipxegeneric-collections)

[![Source Code](https://camo.githubusercontent.com/5c030922ea97899c48c2b6bc68ba76cbaf4f205bd7e3a00eb021116e4b6b3021/687474703a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d65636c6970786531332f67656e657269632d2d636f6c6c656374696f6e732d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/eclipxe13/generic-collections)[![Latest Version](https://camo.githubusercontent.com/7a688fe1c9132ac397ca2e330d5cc7c456cf09fee9065ba9cdced55ee671ac4c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f65636c6970786531332f67656e657269632d636f6c6c656374696f6e732e7376673f7374796c653d666c61742d737175617265)](https://github.com/eclipxe13/generic-collections/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/eclipxe13/generic-collections/blob/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/387ccd78c4114b3cfd8878c23a37942d22ef8660c83e3baf1d6c9c4c3d37e443/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f65636c6970786531332f67656e657269632d636f6c6c656374696f6e732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/eclipxe13/generic-collections?branch=master)[![Scrutinizer](https://camo.githubusercontent.com/34570b8f02e799f339f7d68a34bb4b4618f435c157951af534b231aa92cdb22f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f65636c6970786531332f67656e657269632d636f6c6c656374696f6e732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/eclipxe13/generic-collections/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/60344bfaa3f4f25875e1a561fd6b900c989012ec9832fff4ac10146183290577/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f65636c6970786531332f67656e657269632d636f6c6c656374696f6e732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/eclipxe13/generic-collections/code-structure/master)[![Total Downloads](https://camo.githubusercontent.com/0261894062a661a6da16b0960b54cf86b52dd9802b1fecfb1b73ba5f3ca4d4b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f65636c697078652f67656e657269632d636f6c6c656374696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/eclipxe/generic-collections)[![SensioLabsInsight](https://camo.githubusercontent.com/b46c74ffb0103879a42a64a102c0f4816ac51443b80c624ecac082837ebe0423/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f65656237303939642d653335642d346163622d386365322d3435373030346134373931332f6d696e692e706e67)](https://insight.sensiolabs.com/projects/eeb7099d-e35d-4acb-8ce2-457004a47913)

Generic Collections PHP Library is a PHP 5.6+ that mimics the [Java Collections Framework](http://docs.oracle.com/javase/8/docs/technotes/guides/collections/index.html).

As PHP does not have Generics this library will always implements type checks. Don't worry, anyways you can always use the `mixed` type

For concrete classes uses a constructor approach:

```
// collection = new Collection();
$collection = new Collection(Foo::class);
```

For your own classes you could extend the abstract class and implement the appropiated type methods, by example:

```
class Foos extends Collection
{
    public function __construct(array $elements)
    {
        parent::__construct(Foo::class, $elements);
    }
}
```

Installation
------------

[](#installation)

The preferred method of installation is via [Packagist](https://packagist.org/packages/eclipxe/generic-collections) and [Composer](http://getcomposer.org/). Run the following command to install the package and add it as a requirement to your project's `composer.json`:

```
composer require eclipxe/generic-collections
```

List of classes
---------------

[](#list-of-classes)

Basic classes:

- Collection: A collection represents a group of elements of the same type.
- Set: A collection that only allows unique elements
- Queue: Collection for holding elements (FIFO)
- Deque: Double Ended Queue

Classes that implement `\ArrayAccess`

- Map: A mapping from keys to values.
- List: A collection that can be accessed by their integer index and search elements on the list.

Additional classes:

- Stack: Collection for holding elements (LIFO)
- ShapeTypedStruct: Structure with typed values (also with `\ArrayAccess`)

All classes have these additional options:

- allow null elements/values
- allow only unique elements/values
- comparison equal (make equality comparisons between members instead of identical comparisons)

About
-----

[](#about)

This library is inspired by the Java Collections Framework and PHP [ramsey/collection](https://github.com/ramsey/collection) library.

I see significant changes with ramsey's package, as I didn't want to introduce heavy changes to his API I decide to create my own approach.

I had also take a deep search on [Packagist](https://packagist.org/packages/eclipxe/generic-collections) but couldn't find a library that ensure type checking on members.

Yes, my mistake, the repository username is `eclipxe13/` and the packagist name is `eclipxe/`.

Compatibility
-------------

[](#compatibility)

This class will be compatible according to [PHP Supported versions](http://php.net/supported-versions.php), Security Support. This means that it will offer compatibility with PHP 5.6+ until 2018-12-31.

The support for version 5.5+ is not included since this PHP version will end 2016-06-10 and that is lower than the release of first version of this library.

Not taking particular efforts to make this library compatible with hhvm, hhvm have Generics support included and also has a collection library. I have seen differences on how hack language implement traits (like the ability to use abstracts methods) that are not compatible. Also I've seen a problem on hhvm 3.6.6 (the one is using Travis CI)implementation of `SplDoubleLinkedList` that are not present on version 3.12.1.

Documentation and examples
--------------------------

[](#documentation-and-examples)

WIP. Be patient please.

Contributing
------------

[](#contributing)

Contributions are welcome! Please read [CONTRIBUTING](https://github.com/eclipxe13/generic-collections/blob/master/CONTRIBUTING.md) for details and don't forget to take a look in the [TODO](https://github.com/eclipxe13/generic-collections/blob/master/TODO.md) and [CHANGELOG](https://github.com/eclipxe13/generic-collections/blob/master/CHANGELOG.md) files.

Copyright and License
---------------------

[](#copyright-and-license)

The eclipxe/generic-collections library is copyright © [Carlos C Soto](https://eclipxe.com.mx/)and licensed for use under the MIT License (MIT). Please see [LICENSE](https://github.com/eclipxe13/generic-collections/blob/master/LICENSE) for more information.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~97 days

Total

4

Last Release

3387d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/66964609?v=4)[eclipxe](/maintainers/eclipxe)[@Eclipxe](https://github.com/Eclipxe)

---

Top Contributors

[![eclipxe13](https://avatars.githubusercontent.com/u/1266852?v=4)](https://github.com/eclipxe13 "eclipxe13 (143 commits)")

---

Tags

collectionsgenerics

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/eclipxe-generic-collections/health.svg)

```
[![Health](https://phpackages.com/badges/eclipxe-generic-collections/health.svg)](https://phpackages.com/packages/eclipxe-generic-collections)
```

###  Alternatives

[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k423.8M1.4k](/packages/doctrine-collections)[dusank/knapsack

Collection library for PHP

5351.0M25](/packages/dusank-knapsack)[qaribou/immutable.php

Immutable, highly-performant collections, well-suited for functional programming and memory-intensive applications.

347147.4k](/packages/qaribou-immutablephp)[ilya/belt

A handful of tools for PHP developers.

70820.9k1](/packages/ilya-belt)[chemem/bingo-functional

A simple functional programming library.

687.0k3](/packages/chemem-bingo-functional)[robertmarney/lara-hierarchial-collections

Transforms flat collections to a nested hierarchy

342.3k](/packages/robertmarney-lara-hierarchial-collections)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
