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

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

jausions/php-typed-collections
==============================

Collections and arrays with type constraint.

v1.0.0(8y ago)34.2k1MITPHPPHP ^7.1

Since Mar 8Pushed 2y ago4 watchersCompare

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

READMEChangelog (1)Dependencies (2)Versions (3)Used By (1)

Typed Collections
=================

[](#typed-collections)

Type hinting is evolving but PHP 7 still does not currently provide a way to define the type of the elements of an array.

This library provides traits that can be used to implement type checking.

If you do not wish to implement anything, simply use one of the prebuilt solutions below:

- For Doctrine collections, see this package: [jausions/php-typed-doctrine-collections](https://github.com/jausions/php-typed-doctrine-collections).

For the purpose of this library, the term *type* is used loosely to refer to built-in PHP types, classes, and even application-domain types.

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

[](#installation)

```
composer require jausions/php-typed-collections
```

In the examples below, the `require 'vendor/autoload.php';` is implied.

Simplistic Example
------------------

[](#simplistic-example)

This example only implements the [ArrayAccess PHP Predefined Interface](http://php.net/manual/en/class.arrayaccess.php). This means no `foreach` iteration, `count()`, and so on...

```
