This is useless. You are doing an ``array_replace_recursive`` of 4 arrays with known (and different) keys. Simplify it:

```php
$gridMetadata = array(
    'date' => new MongoDate(),
    'name' => $name,
    'metadata' => $metadata,
    'filename' => $key,
);
```