From:             e dot nash at dvz-mv dot de
Operating system: Win/Linux
PHP version:      5.4.15
Package:          Class/Object related
Bug Type:         Bug
Bug description:get_called_class incorrect after call_user_func to a parent 
static function

Description:
------------
When called from an instance function via call_user_func (or
call_user_func_array), the late static binding appears to not recognise an
explicit call to a parent static function and propagates the caller as the
called class rather than the callee.

When called "directly" the late static binding functions correctly.

To reiterate: there is an inconsistency here between the results with
P::test() and call_user_func('P::test') in the test script below. My
opinion is that this is a bug.

Tested with the script below in PHP 5.3 and PHP 5.4.15.

If this is the expected behaviour ("feature not a bug") then it should be
prominently documented (c.f. bug #47402)

Test script:
---------------
abstract class P {
        static public function test() {
                echo get_called_class();
        }
}
class C extends P {
        public static function runStatic() {
                P::test();
                call_user_func('P::test');
                call_user_func(array('P', 'test'));
        }
        public function run() {
                P::test();
                call_user_func('P::test');
                call_user_func(array('P', 'test'));
        }
}
C::runStatic();
$c = new C();
$c->run();


Expected result:
----------------
Console output:
PPPPPP

Actual result:
--------------
Console output:
PPPPCC

-- 
Edit bug report at https://bugs.php.net/bug.php?id=64914&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64914&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64914&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64914&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64914&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64914&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64914&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64914&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64914&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64914&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64914&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64914&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64914&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64914&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64914&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64914&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64914&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64914&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64914&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64914&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64914&r=mysqlcfg

Reply via email to