#33980 [NEW]: $this refers to the caller in static calls
| From: | gerald at copix dot org | Date: | Wed, 03 Aug 2005 13:52:12 +0000 |
| Subject: | #33980 [NEW]: $this refers to the caller in static calls | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-82883@lists.php.net to get a copy of this message | ||
From: gerald at copix dot org
Operating system: Linux
PHP version: 5.0.3
PHP Bug Type: Class/Object related
Bug description: $this refers to the caller in static calls
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 bug report at http://bugs.php.net/?id=33980&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33980&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33980&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33980&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33980&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33980&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33980&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33980&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33980&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33980&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33980&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33980&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33980&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33980&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33980&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33980&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33980&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33980&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33980&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33980&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33980&r=mysqlcfg