I read some articles about PHP references and how they hurt performance. I also saw some tests, proving the same.
Most of those resources, claim that reason for that is because references disable copy-on-write.
But I don't understand why would that cause a problem? PHP is not going to copy array e.g, just because you passed it by reference.
function foo(&$var) {
$var->test = 'bar';
xdebug_debug_zval('var');
}
$data = new stdclass;
foo($data);
and result I receive
(refcount=3, is_ref=1),
object(stdClass)[1]
public 'test' => (refcount=1, is_ref=0),string 'bar' (length=3)
This shows that no copy was made, and that function is still using same variable (dealing with actual variable and not copy).
What have I missed, why is there a performance loss?