<commit_before># Introduction

## Dependency Injection

_Dependency Injection_ (here-in called DI) refers to the act of providing
dependencies for an object during instantiation or via a method call. A basic
example looks like this:

```php
$b = new MovieLister(new MovieFinder());
```

Above, `MovieFinder` is a dependency of `MovieLister`, and `MovieFinder` was
injected into `MovieLister`.

There are several forms of dependency injection:

- Constructor injection
- Setter injection
- Property (or field) injection

While previous versions of zend-di attempted to handle all three types, starting
in version 3, the component focuses only on the first, constructor injection.
This decision was made for several reasons:

- It simplified the implementation dramatically.
- The simplified implementation had performance benefits.
- It enforces the order of object initialization, which both helps to prevent
  circular dependencies, and ensures the completeness of the instantiated object.

> ### Further reading
>
> If you are not familiar with the concept of DI, here are several great reads:
>
> - [<NAME>'s Analogy](http://weierophinney.net/matthew/archives/260-Dependency-Injection-An-analogy.html)
> - [Ralph Schindler's Learning DI](http://ralphschindler.com/2011/05/18/learning-about-dependency-injection-and-php)
> - [Fabien Potencier's Series](http://fabien.potencier.org/article/11/what-is-dependency-injection) on DI


> ### zend-servicemanager<commit_msg>DI Analogy reference URL updated<commit_after># Introduction

## Dependency Injection

_Dependency Injection_ (here-in called DI) refers to the act of providing
dependencies for an object during instantiation or via a method call. A basic
example looks like this:

```php
$b = new MovieLister(new MovieFinder());
```

Above, `MovieFinder` is a dependency of `MovieLister`, and `MovieFinder` was
injected into `MovieLister`.

There are several forms of dependency injection:

- Constructor injection
- Setter injection
- Property (or field) injection

While previous versions of zend-di attempted to handle all three types, starting
in version 3, the component focuses only on the first, constructor injection.
This decision was made for several reasons:

- It simplified the implementation dramatically.
- The simplified implementation had performance benefits.
- It enforces the order of object initialization, which both helps to prevent
  circular dependencies, and ensures the completeness of the instantiated object.

> ### Further reading
>
> If you are not familiar with the concept of DI, here are several great reads:
>
> - [<NAME>'s Analogy](https://mwop.net/blog/260-Dependency-Injection-An-analogy.html)
> - [<NAME>'s Learning DI](http://ralphschindler.com/2011/05/18/learning-about-dependency-injection-and-php)
> - [<NAME>'s Series](http://fabien.potencier.org/article/11/what-is-dependency-injection) on DI


> ### zend-servicemanager
{'fraction_non_alphanumeric': 0.08875942426319397, 'fraction_numerical': 0.009595613433858808, 'mean_word_length': 4.98155737704918, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3696760', 'n_tokens_mistral': 836, 'n_tokens_neox': 783, 'n_words': 317}