That won’t work, as converting the objects to arrays to merge them removes the reference to the original classes.
Please take a look at the implementation of the File class. It has a __call() method, which gets called for all not explicitly defined methods. It uses the meta() method, which returns $this->cache['meta'], which is an object of type Content.
You can now get the Content object and set your custom data on it. The corresponding methods on the File object should now be callable:
Oh, I missed that you are using thumb(), which works totally differently. It is no File object but a Thumb object, which relies on Media (both are part of the Toolkit).
Media can’t be extended like this though, because it gets its data directly from the file. So what you plan on doing is not directly possible and you will need to choose a different approach:
class CustomMedia extends Media {
public function name() {
return 'my-filename';
}
}
$file = thumb(new CustomMedia($page->image()), array('width' => 300));
echo $file->name(); // my-filename