It actually always worked, but only appeared to be working. It could (and almost always did) end up corrupting data structures. In 4.0.4, this is actively detected, and prevented.
The counterproof is atteched.
Well, trust me, there´s code out there using this procedure and it´s working. I´ve changed that example code to reflect a more realistic situation... and it just doesn´t work NOW and it worked before (tested for example with a 2000-10-01 build) for ages perfectly. Perhaps we can figure out in which case it *should* not work and add a "warning" protection there, but this "fatal error"... umh.
To summarize:
You can´t use returned copies (and references) of variables if directly originating from methods anymore?
Well that´s very bad. Try out the code and notice that changing $bar, also changes these $updated_bar(2) variables and I can´t imagine that this is by accidently corrupted data structures, I could be wrong, sure :)
<?php
class foo {
function &ret1(&$obj1) {
$obj1->a='test';
return $obj1; }
function &why_not(&$obj1) {
$obj1->b='test';
return $obj1; }
}
$bar->xyz=TRUE;
$x = new foo();
$updated_bar =& $x->why_not($foo=&$x->ret1($bar));
$updated_bar2 =& $x->why_not($x->ret1($bar));
$bar->xyz=FALSE;
var_dump($updated_bar);
var_dump($updated_bar2);
?>