On 25 February 2016 at 14:19, Dan Ackroyd <dan...@basereality.com> wrote:
> On 25 February 2016 at 18:16, Adam Harvey <a...@adamharvey.name> wrote:
>>
>> am I right
>> that this is equivalent to the following?
>>
>>$injector->delegate('FooInterface', function (...$args) { return new
> FooImplementation(...$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.

OK, I understand that now. Thanks.

Why is having a special syntax that is considered callable and
conflates instantiation and method calls (which are ultimately
separate things) better than having the injector accept a class name
and use reflection as required to instantiate that?

>> "I only skimmed the RFC"
>
> I find this very dissapointing. Conversations are far more productive
> if people have read the whole of a proposal before deciding how they
> feel about it and giving feedback.

To be clear: I did read the entire RFC, just quickly. Since it seemed
an obvious question to me (and apparently not just me, based on
/r/php), and didn't seem to be addressed that I could see, I thought
it was better to just ask it rather than stay silent and either ask it
several days later or vote -1 without explanation.

> In particular reading the sections "Can't be used as strings in class
> properties" and "Can't be used in string based configuration" would
> give examples where the RFC is of benefit in a way that is not related
> to DIC libraries.

Honestly, I still don't find either of them particularly persuasive,
for the same reasons as the aforementioned DIC example. They're
trivially special cased without muddying instantiation and method
calls. Hence my "are there analogues for this elsewhere" question.

Adam

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to