====== Request for Comments: Indirect method call by array variable ====== * Version: 1.0 * Date: 2011-06-05 * Author: Felipe Pena * Status: Implemented * Published in internals: http://markmail.org/thread/apqqa5lkuuedbbjf ===== Introduction ===== Reading our bug tracker I noticed a good feature request (http://bugs.php.net/bug.php?id=47160) from 2009 which points to an interesting feature that I think makes sense for us, since we are now working with $f() using objects and strings, and the array('class', 'method') is an old known for call_user_func()-like functions. The array to be a valid callback should be a 2-element array, and it must be for the first element object/string and for the second string only. (just like our zend_is_callable() check and opcodes related to init call) ===== Example ===== Checking for callback, nowadays already recognizes array('class', 'method') as valid callback, so it will facility the indirect call through a variable: $callback) { if (is_callable($callback)) { $callback($k); } } ?> Output: Hello, 0 Hello, 1 Hello, 2 ===== Patch ===== - http://felipe.ath.cx/diff/fr47160.diff