When defining a ValueDefinition with
$container->set('foo', $var);
ValueDefinition::isCacheable() will return false if $var is an object.
However, if $var is an array containing unserializable objects, PHP-DI will try to serialize it (and thus an exception will be thrown).