Bug #66719 [Com]: Weird behaviour when using get_called_class() with call_user_func()
| From: | coolwust at gmail dot com | Date: | Sat, 15 Feb 2014 22:44:19 +0000 |
| Subject: | Bug #66719 [Com]: Weird behaviour when using get_called_class() with call_user_func() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-184308@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66719&edit=1
ID: 66719
Comment by: coolwust at gmail dot com
Reported by: coolwust at gmail dot com
Summary: Weird behaviour when using get_called_class() with
call_user_func()
Status: Not a bug
Type: Bug
Package: Class/Object related
Operating System: linux
PHP Version: 5.5.9
Block user comment: N
Private report: N
New Comment:
According to
http://us1.php.net/manual/en/language.types.callable.php
It is valid:
// Type 5: Relative static class method call (As of PHP 5.3.0)
class A {
public static function who() {
echo "A\n";
}
}
class B extends A {
public static function who() {
echo "B\n";
}
}
call_user_func(array('B', 'parent::who')); // A
Previous Comments:
------------------------------------------------------------------------
[2014-02-15 21:40:56] requinix@php.net
array('B', 'parent::who') is not valid: the second element must be the name of a
method. array('B', 'who') is the correct form.
------------------------------------------------------------------------
[2014-02-15 18:28:53] coolwust at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.get-called-class
---
B::who(); should has the same result as call_user_func(array('B',
'parent::who')); But it's not.
See the example below.
Test script:
---------------
<?php
class A
{
public static function who()
{
var_dump(get_called_class());
}
}
class B extends A
{
public static function who()
{
parent::who();
}
}
B::who();
call_user_func(array('B', 'parent::who'));
?>
Expected result:
----------------
string 'B' (length=1)
string 'B' (length=1)
Actual result:
--------------
string 'B' (length=1)
boolean false
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66719&edit=1