#43608 [Opn->Bgs]: get_class() gets __CLASS__ in static methods
| From: | johannes@php.net | Date: | Sun, 16 Dec 2007 18:44:08 +0000 |
| Subject: | #43608 [Opn->Bgs]: get_class() gets __CLASS__ in static methods | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-120681@lists.php.net to get a copy of this message | ||
ID: 43608
Updated by: johannes@php.net
Reported By: mrbizkit at email dot it
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: *
PHP Version: 5.2.5
New Comment:
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
That's an feature implemented with PHP 5.3 called "Late Static
Binding", see: http://php.net/language.oop5.late-static-bindings
Previous Comments:
------------------------------------------------------------------------
[2007-12-16 18:26:48] mrbizkit at email dot it
Description:
------------
hi, i'm asking for a feature change about this function in static
methods and extended classes (please read the reproduce code)
the problem is:
i want to get the caller classname, not the classname where get_class()
is used
if you want to fix it [?]
for retrocompatibility issues you can use get_class(NULL[,true]); or a
new function
Reproduce code:
---------------
class theparent
{
public static function test()
{
echo get_class() . "\n";
//echo get_class(NULL,TRUE) . "\n"; [?]
}
}
class pecl extends theparent{}
class pear extends theparent{}
pecl::test();
pear::test();
Expected result:
----------------
pecl
pear
Actual result:
--------------
theparent
theparent
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43608&edit=1