#35034 [Bgs]: $this != ($this)
| From: | olympic at dino-online dot de | Date: | Tue, 01 Nov 2005 16:51:07 +0000 |
| Subject: | #35034 [Bgs]: $this != ($this) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-87353@lists.php.net to get a copy of this message | ||
ID: 35034
User updated by: olympic at dino-online dot de
Reported By: olympic at dino-online dot de
Status: Bogus
Bug Type: Feature/Change Request
Operating System: *nix
PHP Version: 5.0.5
New Comment:
Following your comment:
$a=new Foo();
$b=$a ; // $b references $a
$c=($a); //$c is now a copy because only variables
are referencable ? (NOPE)
Well, seems a little bitte inconsistent for me, why
different behaviours in assignment and method calls ?
Previous Comments:
------------------------------------------------------------------------
[2005-10-31 12:58:26] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
($this) is an expression, not a variable, thus you can not pass it by
reference.
------------------------------------------------------------------------
[2005-10-31 12:00:17] olympic at dino-online dot de
Description:
------------
$this is treated as references, while ($this) not...
$this != ($this) ?? omg :)
Reproduce code:
---------------
error_reporting(E_ALL);
class Bar {
function onlyByRefPlease(&$foo) {
// ...
}
function someMemberFunc1() {
$this->onlyByRefPlease($this);
}
function someMemberFunc2() {
$this->onlyByRefPlease(($this)); // note: 2 Braces!
}
};
$foo = new Bar();
$foo->someMemberFunc1();
$foo->someMemberFunc2(); // throws error
Expected result:
----------------
/* none */
Actual result:
--------------
Fatal error: Only variables can be passed by reference in
/www/v3.evalanche.com/web/php_refbug.php on line 13
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35034&edit=1