auraphp / Aura.Di

Dependency Injection System
MIT License
349 stars 63 forks source link

Interface setter injection #42

Closed Grummfy closed 10 years ago

Grummfy commented 10 years ago

Same issue than #41

pmjones commented 10 years ago

OMG TABS!

pmjones commented 10 years ago

I believe it may be more complicated than this. For example, say we have an interface "FooInterface" with a method "setFoo()". We create a setter['FooInterface']['setFoo'] = 'whatever'. A class, "Parent", implements the foo interface. We do not create a setter entry for "Parent". Another class, "Child", extends "Parent". We create a setter['Child']['setFoo'] = 'something else'.

The way I think about it, the Child setter value should override the FooInterface setter value. But I think this PR will honor only the FooInterface setter value, and not the Child one.

Does that make sense?

It may be that the interface setters need to be unified first, then the class-level stuff, then the traits.

pmjones commented 10 years ago

Actually it might be as easy as moving the interface work to the top of that method, before the non-trait setters.

Grummfy commented 10 years ago

Perhaps you need to refactore a bit the code and modify some stuff, but it work prety well. Do you want me to make some change, or did you prefere marging it to a branche and adapt the way you prefer?

For info the class implemented are taken from class and parents classes.

ps : Yes, I like tabssssss. Don't be afraid.

pmjones commented 10 years ago

I thought I might have to ask for a modified PR, but on further review I'll take it as is. Thanks!

And on the tabs, not a big deal, but the PSR-2 standards specify spaces. ;-)

Grummfy commented 10 years ago

PSR a re recomendation not the law ... and never forget PSR comes after vote so some choice are no so well thinked ... But if you have some code style you prefer about auraphp I will apply to any other pull request that I could make.

pmjones commented 10 years ago

if you have some code style you prefer about auraphp I will apply to any other pull request

Yes, this and all other Aura packages attempt to comply with PSR-1 and PSR-2. I appreciate your flexibility; thank you, and thanks for the improvements.

pmjones commented 10 years ago

For the record, no changes needed other than moving the interface setter logic to the top of that method, and a couple of aesthetic changes and added tests. Nicely done!