#47335 [NEW]: get_called_class() sometimes returning incorrect value

From: Date: Sat, 07 Feb 2009 14:54:35 +0000
Subject: #47335 [NEW]: get_called_class() sometimes returning incorrect value
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133595@lists.php.net to get a copy of this message
From:             php at kennel17 dot co dot uk
Operating system: Win32
PHP version:      5.3.0beta1
PHP Bug Type:     Unknown/Other Function
Bug description:  get_called_class() sometimes returning incorrect value

Description:
------------
The new get_called_class() function returns the wrong class name when
called from within a static method, when that function is called from an
instantiated class method.

Reproduce code:
---------------
<?php

class MyClass {
	function GetClassName() {
		return get_called_class();
	}
}

class OtherClass {
	function Foo() {
		return MyClass::GetClassName();
	}
}

$c = new OtherClass;

print( MyClass::GetClassName() . "\n");
print( OtherClass::Foo() . "\n");
print( $c->Foo() . "\n");

?>

Expected result:
----------------
MyClass
MyClass
MyClass


Actual result:
--------------
MyClass
MyClass
OtherClass


-- 
Edit bug report at http://bugs.php.net/?id=47335&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        http://bugs.php.net/fix.php?id=47335&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        http://bugs.php.net/fix.php?id=47335&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        http://bugs.php.net/fix.php?id=47335&r=trysnapshot60
Fixed in CVS:                        http://bugs.php.net/fix.php?id=47335&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47335&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=47335&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=47335&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=47335&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=47335&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=47335&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=47335&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=47335&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=47335&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=47335&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47335&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47335&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=47335&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=47335&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=47335&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=47335&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=47335&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#133595) next »