I've never had an issue like this before - in any language in fact.
I have an object originally from JSON. I don't want to alter this object, and will use it merely as a copy for various purposes.
In this example, the object I don't want to alter has lorem ipsum, as I've deemed the actual contents irrelevant.
//Inside the Object I don't want to alter, consider it a template/structure: {"random_key"=>"","another_random_key_with_an_int"=>1}
function random_func(){
$local_scope_object = $this->original_instance;
$local_scope_object->random_key = "now has data";
return $local_scope_object;
}
As you can see above, there's an object returned to the handler, but lets ignore that for now.
When I var_dump($this->original_instance);
I expect to see the instance unchanged, and its key random_key
to remain empty; but it is affected.
What could this be, because I haven't declared the local scope var like (with the amp &) $local_scope_object = &$this->original_instance
?