Bug fix:
When a Traversable is encountered it is converted to an array.
By default this is done recursively, so that the Traversable becomes an array representation.
The result of that is saved in $this->object.
In the Colletion::extract method when iterating over $this->object there are two branches:
1. If there is a hydrator, its extract method is called which expects $value as an object.
2. If $value is an instance of the targetElement, eventualy setObject($value) is called on a fieldset, which also expects an object. Also the targetElement object is set to $value.

In both cases an object is expected, but because of recursive iteratorToArray call it will never be an object.

The fix is to not do it recursively, this way it still gives a key => value array representation of the traversable,
but still gives model objects that can be used by a hydrator or set as targetElement object.

The above problem occurs when an extended Traversable that implements the toArray method is being used in the ArrayUtils::iteratorToArray method.
Because it is recursive per default, it calls the toArray method on the traversable and in case this is implemented in a way that also calls toArray on all child elements, the whole traversable is converted to a scalar-only-array.
So now that there are no object, the Zend\Form\Element\Collection::extract method can not use the hydrator extract method on an array. Also the targetElement hydrator can not do it.
So the extract method fails even though there is probably an array containing a lot of nice values.

The solution chosen by me is to not recursively transform. That works as shown in the two added testcases.
Another fix would be to rewrite the way the extract method works. Or to better dictate how the traversable should be constrained to be transformed in a more controlled way.
Merge pull request #5220 from dhensen/form-collection-extract-bug

Bug fix for Zend\Form\Element\Collection::extract()

Conflicts:
	tests/ZendTest/Form/Element/CollectionTest.php
[#5220] CS fixes

- EOF ending
Merge branch 'hotfix/5220'

Close #5220