auraphp / Aura.Di

Dependency Injection System
MIT License
349 stars 63 forks source link

Issue with the documentation #89

Closed settermjd closed 9 years ago

settermjd commented 9 years ago

The documentation states the following:

If we were to try to set a service using $di->lazyNew('ExampleWithParams'), the instantiation would fail. The $foo param is required, and the Container does not know what to use for that value.

To remedy this, we tell the Container what values to use for each ExampleWithParams constructor parameter by name using the $di->params array:

However, I'm using PHP 5.5.12-2ubuntu4.4 (currently upgrading an old laptop) and can instantiate lazy load a class, which requires parameters, as the documentation suggests, without providing parameter details to the DI container. Doing a var_dump of the instantiated object shows the following:

object(ExampleWithParams)#9 (2) { ["foo":protected]=> NULL ["bar":protected]=> NULL } 

I'm not sure if I've missed something or not. But if not, wanted to point this out.

pmjones commented 9 years ago

Are you using a 2.x container, or a 3.x one? In 2.x, auto-resolution is on by default, which the documentation you quoted may not take into account.

settermjd commented 9 years ago

@pmjones thanks for clarifying that. I was just re-reading that section of the, 2.0, documentation and saw that that's what was happening. I was using 2.0, not 3. Btw, I'm really liking Aura.