<p dir="auto"><strong>Symfony version(s) affected</strong>: 4.2.5</p>
<p dir="auto"><strong>Description</strong><br>
Issue is related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="428852708" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/30854" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/30854/hovercard" href="https://github.com/symfony/symfony/issues/30854">#30854</a><br>
A Service defined in separate file (but not services_{env}.yaml) loose to autowiring in services.yaml</p>
<p dir="auto"><strong>How to reproduce</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# config/services/extra.yaml
services:
    _defaults:
          autowire: true
          autoconfigure: true

    App\Foo:
        arguments:
            $bar: 'string'"><pre class="notranslate"><code class="notranslate"># config/services/extra.yaml
services:
    _defaults:
          autowire: true
          autoconfigure: true

    App\Foo:
        arguments:
            $bar: 'string'
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# config/services.yaml
imports:
    - {resource: 'services/extra.yaml'}

services:
    _defaults:
        autowire: true
        autoconfigure: true


    App\:
        resource: '../src/*'
        exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'

    App\Controller\:
        resource: '../src/Controller'
        tags: ['controller.service_arguments']"><pre class="notranslate"><code class="notranslate"># config/services.yaml
imports:
    - {resource: 'services/extra.yaml'}

services:
    _defaults:
        autowire: true
        autoconfigure: true


    App\:
        resource: '../src/*'
        exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'

    App\Controller\:
        resource: '../src/Controller'
        tags: ['controller.service_arguments']
</code></pre></div>
<p dir="auto">Then I got a message <code class="notranslate">Cannot resolve argument $foo of "App\Controller\DefaultController::index()": Cannot autowire service "App\Foo": argument "$bar" of method "__construct()" is type-hinted "string", you should configure its value explicitly</code></p>
<p dir="auto"><strong>Additional context</strong><br>
In same time moving  services/extra.yaml to services_dev.yaml will solve the problem. <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/nicolas-grekas/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/nicolas-grekas">@nicolas-grekas</a> <a href="https://github.com/symfony/symfony/issues/30854#issuecomment-479569049" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/30854/hovercard">said</a> it depends on definition order but I would really expect autowiring has less priority than services defined by hands.</p>
<p dir="auto"><strong>Symfony version(s) affected</strong>: 4.2.4 (not tested on previous versions)</p>
<p dir="auto"><strong>Description</strong><br>
Services declared in a separate file imported in <code class="notranslate">services.yaml</code> are not initialized correctly.<br>
It looks like the <code class="notranslate">autowire: false</code> is not taken into account? <g-emoji class="g-emoji" alias="thinking" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f914.png">🤔</g-emoji></p>
<p dir="auto"><strong>How to reproduce</strong><br>
See relevant commit in this dedicated repository:<br>
<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/odolbeau/symfony_dic_bug/commit/97d710645efae62d0fe1c50b586b96f46a6f8767/hovercard" href="https://github.com/odolbeau/symfony_dic_bug/commit/97d710645efae62d0fe1c50b586b96f46a6f8767">odolbeau/symfony_dic_bug@<tt>97d7106</tt></a></p>
<p dir="auto">I have the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Circular reference detected for service &quot;App\Storage\CacheStorage&quot;, path: &quot;App\Storage\CacheStorage -&gt; App\Storage\CacheStorage&quot;."><pre class="notranslate"><code class="notranslate">Circular reference detected for service "App\Storage\CacheStorage", path: "App\Storage\CacheStorage -&gt; App\Storage\CacheStorage".
</code></pre></div>
<p dir="auto">If you move the configuration from <code class="notranslate">custom_services.yaml</code> to <code class="notranslate">services.yaml</code> &amp; remove the <code class="notranslate">imports</code> at the beginning of the file, it works as expected.<br>
If you remove the <code class="notranslate">imports</code> at the beginning of the <code class="notranslate">services.yaml</code> and include <code class="notranslate">custom_services.yaml</code> from the Kernel (method: <code class="notranslate">configureContainer</code>) it works as expected as well.</p>