#43408 [Opn->Asn]: get_called_class not working as expected

From: Date: Wed, 12 Dec 2007 10:36:30 +0000
Subject: #43408 [Opn->Asn]: get_called_class not working as expected
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120598@lists.php.net to get a copy of this message
ID: 43408 Updated by: tony2001@php.net Reported By: bate@php.net -Status: Open +Status: Assigned Bug Type: Scripting Engine problem PHP Version: 6CVS-2007-11-26 (snap) -Assigned To: +Assigned To: colder New Comment: Assigned to the author of the LSB patch. Previous Comments: ------------------------------------------------------------------------ [2007-11-26 09:44:10] bate@php.net Description: ------------ The Function get_called_class works not as expected. the new introduced static call works correct, the self call too but if you call the demo class with parent you dont get foo as result. This should be so because its not possible to overwrite a existing class in a static class with late static binding. get_called_class() should return in every call 'foo' and not as shown with parent::demo() a 'bar' Reproduce code: --------------- <?php abstract class bar { public static function demo() { var_dump(get_called_class()); } } class foo extends bar { public static function parent_demo() { parent::demo(); } public static function self_demo() { self::demo(); } public static function static_demo() { static::demo(); } } echo 'bar::demo()' . PHP_EOL; bar::demo(); echo 'foo::demo()' . PHP_EOL; foo::demo(); echo 'foo::parent_demo()' . PHP_EOL; foo::parent_demo(); echo 'foo::self_demo()' . PHP_EOL; foo::self_demo(); echo 'foo::static_demo()' . PHP_EOL; foo::static_demo(); ?> Expected result: ---------------- bar::demo() string(3) "bar" foo::demo() string(3) "foo" foo::parent_demo() string(3) "bar" foo::self_demo() string(3) "foo" foo::static_demo() string(3) "foo" Actual result: -------------- bar::demo() string(3) "bar" foo::demo() string(3) "foo" foo::parent_demo() string(3) "foo" foo::self_demo() string(3) "foo" foo::static_demo() string(3) "foo" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43408&edit=1

« previous php.bugs (#120598) next »