auraphp / Aura.Di

Dependency Injection System
MIT License
349 stars 63 forks source link

Bug in docs for the container's lazy() method #131

Closed djmattyg007 closed 8 years ago

djmattyg007 commented 8 years ago

It would appear there is a bug in the documentation for the container's lazy() method: https://github.com/auraphp/Aura.Di/blame/77b6597fe58338578d975d6134b436ac24255f1a/docs/lazy.md#L145

Here, an object is constructed using the container's newInstance() method, which locks the container. The following line attempts to define a new service in the container using the set() method, which should immediately through an exception as the container has been locked.

I would have submitted a PR for this, but I wasn't sure of the best way to provide the same example without this bug.

harikt commented 8 years ago

@djmattyg007 you are absolutely correct. The newInstance cannot be used over https://github.com/auraphp/Aura.Di/blob/be6edc07eb3f2277b46b9a19bbe0978178366cee/docs/lazy.md#generic-lazy-calls .

I believe the second example could be removed or may be altered with new SomeObject .