Hi Dan, Dan Ackroyd wrote:
On 25 February 2016 at 18:16, Adam Harvey <[email protected]> wrote:am I right that this is equivalent to the following? $injector->delegate('FooInterface', function (...$args) { return newFooImplementation(...$args); }); Nope. The vital part you missed is that with the original function, all of the parameters (aka dependencies of the class) can be found through reflection, and so can be created by the injector as needed. By using function (...$args){} - all of the parameter information is lost, and so isn't usable by an autowiring-injector.
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.
So it's still worth questioning whether this needs to be a built-in function.
Thanks! -- Andrea Faulds https://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
