#33980 [Csd->Bgs]: $this refers to the caller in static calls
| From: | tony2001@php.net | Date: | Wed, 03 Aug 2005 14:21:27 +0000 |
| Subject: | #33980 [Csd->Bgs]: $this refers to the caller in static calls | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-82886@lists.php.net to get a copy of this message | ||
ID: 33980
Updated by: tony2001@php.net
Reported By: gerald at copix dot org
-Status: Closed
+Status: Bogus
Bug Type: Class/Object related
Operating System: Linux
PHP Version: 5.0.3
Previous Comments:
------------------------------------------------------------------------
[2005-08-03 16:19:55] gerald at copix dot org
My mistake, next time I'll pay more attention to the
documentation.
------------------------------------------------------------------------
[2005-08-03 15:56:25] 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
.
------------------------------------------------------------------------
[2005-08-03 15:52:12] gerald at copix dot org
Description:
------------
$this refers to the caller in static calls of non-static methods.
If the function is correctly set as static, then $this is ok.
That may be a problem as I'm provinding a library that has to be
PHP4/PHP5 compliant.
(in PHP4, "$this" would have not been set)
Reproduce code:
---------------
$obj = new Caller ();
$obj->showResult ();
class Caller {
function showResult (){
echo StaticClass::staticCallAsOfPHP4 ();
}
}
class StaticClass {
static function staticCallAsOfPHP4 (){
return (isset ($this)) ? get_class ($this) : 'none';
}
}
Expected result:
----------------
"none "
(because of the static call, as of PHP4)
Actual result:
--------------
"Caller"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33980&edit=1