Hi, 2015-03-19 17:17 GMT+01:00 S.A.N <ua.san.a...@gmail.com>: >> Then how would you write an callback containing an already constructed >> object? >> $a = [$object, 'method']; >> >> The alternative is unnecessarily cumbersome: >> $a = function($methodArg1, $methodArg2) use($object) { return >> $object->method($methodArg1, $methodArg2); }; > > $object->$methodName(...$args);
You would still need an array to pass the information about the callback to another context. The syntax you detailed is not usable by the callable typehint and internal functions requiring a callback. No improvement made. The better alternative may be to deprecate strings as callbacks (if one should be deprecated at all) and always require a closure or or an array with one of the following signatures array(string); array(string, string); array(object, string) Another way to unify array and string callback may be to use the callable syntax and have it return a closure: callable('strlen'); callable($object, $methodName); callable('class', 'staticMethod') -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php