#18926 [NEW]: call_user_func_array does not mirror normal scope inside class functions

From: Date: Thu, 15 Aug 2002 21:10:05 +0000
Subject: #18926 [NEW]: call_user_func_array does not mirror normal scope inside class functions
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-16939@lists.php.net to get a copy of this message
From: tater@potatoe.com Operating system: Mac OS X 10.1.5 / Darwin 5.5 PHP version: 4CVS-2002-08-15 PHP Bug Type: Scripting Engine problem Bug description: call_user_func_array does not mirror normal scope inside class functions Using call_user_func_array() inside a class function produces different results from the equivalent direct function calls. call_user_func_array(array('self,'method'), $args) gives an error, although self::method() works, as does call_user_func_array(array('myclassname','method'), $args). (This format for calling static class methods is undocumented, by the way - is it officially even supposed to work?) Also, in PHP 4.3-dev, a call to myfunction() inside a class function will check the current class's function table first, before calling a globally defined function. But call_user_func_array('myfunction',$args) does not - it only looks for global functions. Whether any of these things are bugs or features, I don't know. test script: <?php class foo { function myname() { return 'foo'; } function myself() { $args = func_get_args(); echo '<li>', self::myname(), '::myself - my args are ',var_export($args,TRUE),"\n"; } } class bar extends foo { function myname() { return 'bar'; } function test() { foo::myself('calling foo::myself'); bar::myself('calling bar::myself'); self::myself('calling self::myself'); parent::myself('calling parent::myself'); call_user_func_array(array('foo','myself'), array('call_user_func_array on array("foo","myself")')); call_user_func_array(array('bar','myself'), array('call_user_func_array on array("bar","myself")')); call_user_func_array(array('parent','myself'), array('call_user_func_array on array("parent","myself")')); call_user_func_array(array('self','myself'), array('call_user_func_array on array("self","myself")')); myself('calling myself'); call_user_func_array('myself', array('call_user_func_array on "myself"')); } } function myself() { echo '<li>i am the external function myself - my args are ', var_export(func_get_args(), TRUE), "\n"; } bar::test('testing',1,2); ?> -- Edit bug report at http://bugs.php.net/?id=18926&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=18926&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=18926&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=18926&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=18926&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=18926&r=support Expected behavior: http://bugs.php.net/fix.php?id=18926&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=18926&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=18926&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=18926&r=globals

« previous php.bugs (#16939) next »