<commit_before># Default Autowire

[![Build Status](https://img.shields.io/travis/Symplify/DefaultAutowire.svg?style=flat-square)](https://travis-ci.org/Symplify/DefaultAutowire)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/Symplify/DefaultAutowire.svg?style=flat-square)](https://scrutinizer-ci.com/g/Symplify/DefaultAutowire)
[![Downloads](https://img.shields.io/packagist/dt/symplify/default-autowire.svg?style=flat-square)](https://packagist.org/packages/symplify/default-autowire)

**This bundle turns on autowire for you!**

It turns this:

```yaml
# app/config/config.yml
services:
    price_calculator:
        class: PriceCalculator
        autowire: true

    product_repository:
        class: ProductRepository
        autowire: true

    user_factory:
        class: UserFactory
        autowire: true
```

Into this:

```yaml
# app/config/config.yml
services:
    price_calculator:
        class: PriceCalculator

    product_repository:
        class: ProductRepository

    user_factory:
        class: UserFactory
```

# Install

```bash
composer require symplify/default-autowire
```

Add bundle to `AppKernel.php`:

```php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            new Symplify\DefaultAutowire\SymplifyDefaultAutowireBundle(),
            // ...
        ];
    }
}
```


And that's it!


# Features

## Multiple service of one type? Set preferred one

In case you have multiple connections, entity managers or decorated service,
**you can set default preferred service (name) for each type (class or interface)**.

To make it easier for you, there are few default values. You can change them or add new ones.

```yaml
# app/config/cofing.yml
symplify_default_autowire:
    autowire_types:
        Doctrine\ORM\EntityManager: 'doctrine.orm.default_entity_manager'
        Doctrine\ORM\EntityManagerInterface: 'doctrine.orm.default_entity_manager'
        Doctrine\Portability\Connection: 'database_connection'
        Symfony\Component\EventDispatcher\EventDispatcher: 'event_dispatcher'
        Symfony\Component\EventDispatcher\EventDispatcherInterface: 'event_dispatcher'
        Symfony\Component\Translation\TranslatorInterface: 'translator'
```


# Testing

```bash
vendor/bin/symplify-cs check src tests
vendor/bin/phpunit
```


# Contributing

Rules are simple:

- new feature needs tests
- all tests must pass
- 1 feature per PR

I'd be happy to merge your feature then.<commit_msg>packages: unite README, drop static check from multi-repo<commit_after># Default Autowire

[![Build Status](https://img.shields.io/travis/Symplify/DefaultAutowire.svg?style=flat-square)](https://travis-ci.org/Symplify/DefaultAutowire)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/Symplify/DefaultAutowire.svg?style=flat-square)](https://scrutinizer-ci.com/g/Symplify/DefaultAutowire)
[![Downloads](https://img.shields.io/packagist/dt/symplify/default-autowire.svg?style=flat-square)](https://packagist.org/packages/symplify/default-autowire)

**This bundle turns on autowire for you!**

It turns this:

```yaml
# app/config/config.yml
services:
    price_calculator:
        class: PriceCalculator
        autowire: true

    product_repository:
        class: ProductRepository
        autowire: true

    user_factory:
        class: UserFactory
        autowire: true
```

Into this:

```yaml
# app/config/config.yml
services:
    price_calculator:
        class: PriceCalculator

    product_repository:
        class: ProductRepository

    user_factory:
        class: UserFactory
```

# Install

```bash
composer require symplify/default-autowire
```

Add bundle to `AppKernel.php`:

```php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            new Symplify\DefaultAutowire\SymplifyDefaultAutowireBundle(),
            // ...
        ];
    }
}
```


And that's it!


# Features

## Multiple service of one type? Set preferred one

In case you have multiple connections, entity managers or decorated service,
**you can set default preferred service (name) for each type (class or interface)**.

To make it easier for you, there are few default values. You can change them or add new ones.

```yaml
# app/config/cofing.yml
symplify_default_autowire:
    autowire_types:
        Doctrine\ORM\EntityManager: 'doctrine.orm.default_entity_manager'
        Doctrine\ORM\EntityManagerInterface: 'doctrine.orm.default_entity_manager'
        Doctrine\Portability\Connection: 'database_connection'
        Symfony\Component\EventDispatcher\EventDispatcher: 'event_dispatcher'
        Symfony\Component\EventDispatcher\EventDispatcherInterface: 'event_dispatcher'
        Symfony\Component\Translation\TranslatorInterface: 'translator'
```


## Contributing

Send [issue](https://github.com/Symplify/Symplify/issues) or [pull-request](https://github.com/Symplify/Symplify/pulls) to main repository.
{'fraction_non_alphanumeric': 0.10914216673378976, 'fraction_numerical': 0.0002013693113169553, 'mean_word_length': 3.789778206364513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4907080', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1488, 'n_words': 327}