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

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

vistik/typed-collections
========================

A simple way to create typed collections in PHP - build on Illuminate\\Support\\Collection

v2.0.2(8y ago)1128.2k↓33.3%3[1 PRs](https://github.com/vistik/typed-collections/pulls)5MITPHPPHP &gt;=7.0.0

Since Feb 12Pushed 6y ago3 watchersCompare

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

READMEChangelog (3)Dependencies (4)Versions (5)Used By (5)

[![Build Status](https://camo.githubusercontent.com/33ae2e1a778508121c9da0bdf35ea5af0e1ccd3c311f3f0f82cf73bb56ac0f78/68747470733a2f2f7472617669732d63692e6f72672f76697374696b2f74797065642d636f6c6c656374696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vistik/typed-collections)

### What is this?

[](#what-is-this)

This is a very simple way to make arrays type hinted!

`$list = new UserCollection(new User());`

OK

`$list = new UserCollection('User');`

Will throw:

`Vistik\Exception\InvalidTypeException: Item (string) 'User' is not a Vistik\Example\User object!`

### Install

[](#install)

Run `composer require vistik/typed-collections`

### Use build in Collections for primitives

[](#use-build-in-collections-for-primitives)

Out-of-the-box collections for:

- Booleans
- Integers
- Floats
- Strings
- Emails
- Numbers (float or int)

They can be created with out-of-the-box laraval style helpers:

- `bCollect([true, false])` - To create a BoolCollection
- `iCollect([1, 2, 3, 4])` - To create a IntegerCollection
- `fCollect([3.14, 22/7, 6.66])` - To create a FloatCollection
- `sCollect(['hello', 'world''])` - To create a StringCollection
- `eCollect(['hello@example.org', 'write@me.com'])` - To create a EmailCollection
- `nCollect([1, 2, 3, 4, 3.14, INF])` - To create a NumberCollection

### Do I have to create a type for each list? Yes, but

[](#do-i-have-to-create-a-type-for-each-list-yes-but)

Look how easy it is:

```
use Phpsafari\Example\User;
class UserCollection extends TypedCollection{
    protected $type = User::class;
}

```

2 simple steps

1. Create a Class eg. `AccountCollection` extend `TypedCollection`
2. Just replace `protected $type = 'Vistik\Example\User';` with your class

or

If the check is more then just a `is_a` check, you can overwrite the function: `isValidItem($item)` in your new Collection class

### Features

[](#features)

- Build upon [Illuminate\\Support\\Collection](https://github.com/illuminate/support)
- Very simple to implement custom Collections

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~83 days

Total

3

Last Release

3209d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/778d5a66387a519744a13323544a11649c3c52bdb7207319c473a4154ce5335f?d=identicon)[vistik](/maintainers/vistik)

---

Top Contributors

[![vistik](https://avatars.githubusercontent.com/u/354169?v=4)](https://github.com/vistik "vistik (70 commits)")

---

Tags

collectionslaravellaravel-collectionsphp-libraryphp7type-hintstype-safearraytype-hintcollectioncollectionstype hinted

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vistik-typed-collections/health.svg)

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

###  Alternatives

[doctrine/collections

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

6.0k411.1M1.2k](/packages/doctrine-collections)[aimeos/map

Easy and elegant handling of PHP arrays as array-like collection objects similar to jQuery and Laravel Collections

4.2k412.9k11](/packages/aimeos-map)[athari/yalinqo

YaLinqo, a LINQ-to-objects library for PHP

4561.2M5](/packages/athari-yalinqo)[yansongda/supports

common components

211.4M31](/packages/yansongda-supports)[rotexsoft/versatile-collections

A collection package that can be extended to implement things such as a Dependency Injection Container, RecordSet objects for housing database records, a bag of http cookies, or technically any collection of items that can be looped over and whose items can each be accessed using array-access syntax or object property syntax.

186.0k1](/packages/rotexsoft-versatile-collections)[armincms/json

A Laravel Nova field.

25149.4k3](/packages/armincms-json)

PHPackages © 2026

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