auraphp / Aura.Di

Dependency Injection System
MIT License
349 stars 63 forks source link

Add auto-resolution capability #58

Closed pmjones closed 10 years ago

pmjones commented 10 years ago

This allows type hinted constructor params, that do not have explicit DI values, to receive new instances of their type hinted classes. It also allows explicit auto-resolution of type hints to a specific class or service. Incidentally, params type hinted to array will receive empty arrays when no explicit value is passed.

pmjones commented 10 years ago

Ping @hidenorigoto @madapaja @djmattyg007 @tailwindsllc @szkshi @atakig @suzuyan @exsuzukishuhei @mnapoli @pies @bytephp @timw4mail @mosiyash @jleider @nubs @harikt @phpingguo @koriym @jblotus @isimmons @happyaccidents @yagmikita @jeremeamia @mihaeu @atelierdisko @kumamidori @Flugund @williamsodell @njasm @rjmackay @ushahidi

pmjones commented 10 years ago

Also ping @mbrevda and @adriengibrat who have explicitly asked for this.

pmjones commented 10 years ago

See also mailing list discussion at https://groups.google.com/forum/#!topic/auraphp/aeaEV-5Q76A

mbrevda commented 10 years ago

Thanks for remembering! Let me see if I can fit this in to the workflow somewhere...

harikt commented 10 years ago

I would like to ping @TomBZombie for he is doing bench marking of di containers .

adriengibrat commented 10 years ago

I'll be happy to update my benchmark : https://github.com/adriengibrat/benchmarking-dependency-injection-containers 6 month ago the results was: http://adriengibrat.github.io/benchmarking-dependency-injection-containers/

djmattyg007 commented 10 years ago

I haven't yet had a chance to read over the patch (in fact, I haven't been keeping up with it for a few months now, so I've got a bit of catchup work to do), but from the description and the mailing list discussion, I like it quite a bit.

I do have one question: how is the callable type hint supported? "Not at all" is a perfectly good answer, I just wanted to make sure it'd been thought of and won't crash the code.

pmjones commented 10 years ago

@djmattyg007 As far as "callable" there's no way I can think of to auto-resolve it. There's no class associated with it, so we can't instantiate anything; and unlike "array" there's no one canonical callable representation. So I don't see that it can be supported by auto-resolution. In short, "not at all" AFAICT. ;-)

harikt commented 10 years ago

I am good with this. May be we press the green button :+1: .

pmjones commented 10 years ago

Green button it is.

cordoval commented 10 years ago

:+1:

mbrevda commented 10 years ago

Were the docs updated?

On Tue, Sep 2, 2014 at 8:59 PM, Luis Cordova notifications@github.com wrote:

[image: :+1:]

— Reply to this email directly or view it on GitHub https://github.com/auraphp/Aura.Di/pull/58#issuecomment-54191911.

pmjones commented 10 years ago

No, that's the very next task. I think a full README rewrite is in order at this point.

pmjones commented 10 years ago

FWIW all the pre-existing idioms work unchanged.

mbrevda commented 10 years ago

I didnt say "requires" :). And yes, the current readme is a bit of a ramble...

On Tue, Sep 2, 2014 at 9:03 PM, Paul M. Jones notifications@github.com wrote:

FWIW all the pre-existing idioms work unchanged.

— Reply to this email directly or view it on GitHub https://github.com/auraphp/Aura.Di/pull/58#issuecomment-54192476.

adriengibrat commented 10 years ago

Benchmark updated: http://adriengibrat.github.io/benchmarking-dependency-injection-containers/

pmjones commented 10 years ago

That's very heartening. :-)

harikt commented 10 years ago

:+1: