On Fri, 2016-02-26 at 11:30 +0000, Andrea Faulds wrote: > This is true for a trivial implementation like the one above, but I > would point out that a more sophisticated userland implementation could > fix this by generating PHP code.
You don't have to generate PHP code for this to work: $arr = is_string($func) ? explode("::", $func, 2) : $func; $ref = (sizeof($arr) === 2) ? new ReflectionMethod($arr[0], $arr[1]) : new ReflectionFunction($func); $args = identifyArgumentsAndGetCtorArgs($ref); if (sizeof($arr) === 2 && $arr[1] === '__construct') { $rc = new ReflectionClass($arr[0]); return $rc->newInstanceArgs($args); } else { return $ref->invokeArgs($args); } I haven't tested this and it might need some fine tuning, but isn't really complicated. (Of course you can generate PHP code for this trivially in order to avoid the small reflection overhead) > So it's still worth questioning whether this needs to be a built-in > function. I think it is quite obscure and a hardly used feature. Language features and syntax sugar things should be common things. johannes
signature.asc
Description: This is a digitally signed message part