zendframework/zf2 — pull request #5347 by stefanotorresi (2013-10-25 15:17:26+00:00)
Title: Add Traversable merge capability to Stdlib\ArrayUtils:merge()

I don't know if this will be accepted, since reading #880 and #882 it looks like `ArrayUtils::merge()` is only meant to merge plain arrays.

Nevertheless, I've got a use case for this: merging convenience `Config` classes in service locator configurations.

At the moment, trying to do this:
```php
// inside a module
public function getServiceConfig()
{
return array(
// ideally we would instantiate a new custom configuration
// with callables defined in it
'factories' => new \Zend\Config\Config(array(
'foo' => function(){ return 'some service' }
)),
);
}
```

will result in a broken service manager configuration, because on `loadModules` event the `factories` key will be overwritten, rather than merged.

I know it would suffice to invoke `Config::toArray()`, but it looks a bit obnoxious imho.

Thoughts?