$ref =& $this;
| From: | Derick Rethans | Date: | Mon, 03 Oct 2005 13:09:22 +0000 |
| Subject: | $ref =& $this; | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-19336@lists.php.net to get a copy of this message | ||
Hello,
Dmitry committed a fix earlier to ignore the & in the statement above. I
think this is not a good thing to do as it's simply conceptually wrong.
The first thing is that ignoring syntax without issuing a warning is
dubious because people might think it does actually work, and secondly
because I think that the code above is wrong anyway - somewhat in the
same way that "$this = new foo();" is wrong.
There is never any need to assign $this by reference, nor to pass it by
reference to a function as it's an object anyway, making the references
pointless - I would even go as far as disallowing passing $this by
references to a function - where the reference has to be ignored again,
otherwise it allows you to chantge $this to a different object with:
class Foo {
function byRef(&$f) {
$f = new Bar();
}
function modifyThis() {
$this->byRef($this);
}
}
I think we should prevent people from writing syntax like this, as it is
not obvious what is going to happen. This means that we should revert
Dmitry's patch.
regards,
Derick
--
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org