doctrine/collections — pull request #9 by iBiryukov (2013-04-11 20:55:49+00:00)
Title: Array collections can not be optionally made type safe by supplying an e...

...xpected type to the constructor

Type hints are great in php. They provide a degree of type safety.
I made a small patch to make collections type safe too.

Usually, in n-to-many relationships, the collection contains only one type of entity.

To maintain type safety, I usually create 'add' methods

```php
function addAddress(Address $address) {
$this->getAddresses()->add($address);
}
```
Instead it would be awesome, if the collection did the type checking for me:

```php
$coll = new ArrayCollection(array(), 'blah\Address');
$coll->add($address); //good
$coll->add($iceCream); //bad, exception raised

```