PHPackages                             hjerichen/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. hjerichen/collections

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

hjerichen/collections
=====================

Collections for daily use.

1.3.0(1y ago)013.6k—0%4MITPHPPHP ^8.2CI failing

Since Mar 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/hjerichen/collections)[ Packagist](https://packagist.org/packages/hjerichen/collections)[ RSS](/packages/hjerichen-collections/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (4)Versions (16)Used By (4)

[![Continuous Integration](https://github.com/hjerichen/collections/workflows/Continuous%20Integration/badge.svg?branch=master)](https://github.com/hjerichen/collections/actions)[![Coverage Status](https://camo.githubusercontent.com/f68e66eb6dc90cbab500d265a121cc8f6b289e3d3edcc7d417af8096792324d5/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f686a6572696368656e2f636f6c6c656374696f6e732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/hjerichen/collections?branch=master)

Collections
===========

[](#collections)

I like the fact that PHP is going the way to type safety, but unfortunately we haven't reached the goal yet. The type safety still has some gaps. One of the most annoying gap is (at least for me) that you cannot specify types for array elements. I don't like it at all to have to specify just "array" as return type.

To avoid this I have created a small set of collections.

#### Primitive Collections

[](#primitive-collections)

With a primitive collection you can specify the return type like "IntegerCollection" and not just "array". You should be careful though, because in high performance applications this might not be a suitable way.

#### Object Collections

[](#object-collections)

There is also an easy way to create a collection for certain classes:

```
