ID: 40061 Updated by: [EMAIL PROTECTED] Reported By: a at b dot c dot de -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: Windows XP SP2 PHP Version: 5.2.0 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 $foo->bar->baz() was possible in PHP 4, too. New in PHP 5 was $foo->bar()->baz() (with "bar" being a function) To your Problem: Just use array($a->b,'foo') as callback. Previous Comments: ------------------------------------------------------------------------ [2007-01-08 11:48:19] a at b dot c dot de Description: ------------ Object callbacks $foo->bar() are represented as arrays array($foo, 'bar'). Since PHP now supports the syntax $foo->bar->baz(), it seems at first sight that callback arrays could be nested similarly. Currently to use the baz() method above in a callback, one must use a temporary variable $temp=$foo->bar, and use array($temp, 'baz') as the callback in the same way that in PHP4 it was necessary to write $temp=$foo->bar; $temp->baz(). It would seem syntactically unambiguous to write the callback as array(array($foo, 'bar'), 'baz'). There is the matter that its first element refers to an object, not a method, but that's what the first element of an array callback is supposed to refer to (static class methods notwithstanding). Reproduce code: --------------- <?php class aclass { public $b; } class bclass { public function foo($v) { return $v*2; } } $t = array('1','2','3','4','5','6','7','8','9'); $a = new aclass; $a->b = new bclass; print_r(array_map(array(array($a, 'b') ,'foo'), $t)); Expected result: ---------------- Array ( [0] => 2 [1] => 4 [2] => 6 [3] => 8 [4] => 10 [5] => 12 [6] => 14 [7] => 16 [8] => 18 ) Actual result: -------------- Warning: array_map(): The first argument, 'Array', should be either NULL or a valid callback in ... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40061&edit=1