#47335 [Opn->Bgs]: get_called_class() sometimes returning incorrect value

From: Date: Sat, 07 Feb 2009 16:21:16 +0000
Subject: #47335 [Opn->Bgs]: get_called_class() sometimes returning incorrect value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133596@lists.php.net to get a copy of this message
 ID:               47335
 Updated by:       felipe@php.net
 Reported By:      php at kennel17 dot co dot uk
-Status:           Open
+Status:           Bogus
 Bug Type:         Unknown/Other Function
 Operating System: Win32
 PHP Version:      5.3.0beta1
 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




Previous Comments:
------------------------------------------------------------------------

[2009-02-07 14:54:35] php at kennel17 dot co dot uk

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 this bug report at http://bugs.php.net/?id=47335&edit=1



Thread (4 messages)

« previous php.bugs (#133596) next »