Heya,

On Mon, Aug 3, 2020, 05:32 3u93n3 <zsidel...@gmail.com> wrote:

> The main idea is to take control over objects creation and injecting
> dependencies.
>
> 1. Some of them are provided through constructor (those, which could only
> be retrieved right before instantiating our object).
> 2. Others are provided through `__inject` and PHP will inject all those
> dependencies automatically. Configuration we define in separate class, and
> pass it's instance into function-helper.
>

Overall, I don't think this is a good candidate for php-src 2 primary
reasons:

 1. This is already possible in userland: you can already define your own
`__inject` method, and, convention-based, rely on it in your own userland
DIC
 2. Setter injection (as well as property injection, and also the proposed
`__inject`) leads to temporal coupling smells. Explained otherwise, your
object instances are not "functioning" right after instantiation, which
makes their API more complex and reduces reliability (they are broken until
injection has happened). Please just use the constructor: it works, and it
is a simple pre-existing injection point 👍

Reply via email to