What is the best way to create a clone of a complex PHP object that includes many references to itself, so that the new object's references point to its own methods and properties, not those of the original object?
I understand from the manual that $new_object = clone $old_object;
creates a shallow copy that keeps references where they are. So presumably $new_object's references will point to methods on the old object?
A comment on that manual page suggests that $new_object = unserialize(serialize($old_object));
is a way to create a deep copy. Sounds promising, I'm not sure exactly what this approach would mean for my case: whether references are converted to point to the clone, or made absolute, or something else, and if does do what I want, whether it's the best way.
I'd like to know if there's an established, standard way to do this.
(Note: the object in question is a Drupal Views object, but this question is about PHP objects in general: the only important features of this object are, that it is huge, and contains many references to itself that recurse if you try to navigate the whole tree.)