#41762 [Bgs]: Fix of bug #30828 means there is no way to get class name statically.
| From: | php at kennel17 dot co dot uk | Date: | Fri, 22 Jun 2007 17:58:25 +0000 |
| Subject: | #41762 [Bgs]: Fix of bug #30828 means there is no way to get class name statically. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-114092@lists.php.net to get a copy of this message | ||
ID: 41762
User updated by: php at kennel17 dot co dot uk
Reported By: php at kennel17 dot co dot uk
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: N/A
PHP Version: 5.2.3
New Comment:
Is there a bug logging this issue already, or shall I create a new one
to request this functionality?
Previous Comments:
------------------------------------------------------------------------
[2007-06-21 22:45:57] johannes@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
Maybe we get a proper implementation for late static binding till then
there is no reliable way to get the information.
------------------------------------------------------------------------
[2007-06-21 12:41:36] php at kennel17 dot co dot uk
Description:
------------
Before bug #30828 was fixed, debug_backtrace() could be used to get the
name of a class when the class was extended from a parent class and
being called statically. The new change removes this functionality, and
as far as I can see there is no replacement. Perhaps, I am just unaware
of an alternative method of achieving this, but if not then this is a
vital piece of functionality that has gone missing!
Reproduce code:
---------------
<?php
function get_class_static() {
$bt = debug_backtrace();
if (isset($bt[1]['object']))
return get_class($bt[1]['object']);
else
return $bt[1]['class'];
}
class foo {
function printClassName() {
print(get_class_static() . "<br>");
}
}
class bar extends foo {
}
foo::printClassName();
bar::printClassName();
?>
Expected result:
----------------
In PHP4 the output was:
foo
bar
Actual result:
--------------
In PHP5 the output is:
foo
foo
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41762&edit=1