PHPackages                             jausions/php-typed-doctrine-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. [Database &amp; ORM](/categories/database)
4. /
5. jausions/php-typed-doctrine-collections

ActiveLibrary[Database &amp; ORM](/categories/database)

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

Typed Doctrine collections (Pseudo-arrays with type constraint)

v1.0.0(8y ago)04.2kMITPHP

Since May 3Pushed 2y ago2 watchersCompare

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

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

Typed Doctrine Collections
==========================

[](#typed-doctrine-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 (a.k.a. Generics.)

This library is built on top of Doctrine/Collections to enforce type checking on elements added to a collection. We could also call them strongly typed arrays.

The aim is to leverage type hinting to help prevent bugs, or, at the very least, detect them earlier in the development cycle.

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-doctrine-collections
```

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

Type Defined by Initial Value
-----------------------------

[](#type-defined-by-initial-value)

The first element passed to the constructor determines the criteria for the elements that come after it.

```
