<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>3.4 (maybe earlier)</td>
</tr>
</tbody>
</table>
<p dir="auto">With default routing and services configuration create a simple controller with a non-service class like this:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?php

namespace App\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;

class IndexController extends AbstractController
{
    /**
     * @Route(name=&quot;index&quot;)
     */
    public function indexAction(A $a)
    {
        dump($a);

        return new Response();
    }
}

class A
{
}"><pre class="notranslate"><span class="pl-ent">&lt;?php</span>

<span class="pl-k">namespace</span> <span class="pl-v">App</span>\<span class="pl-v">Controller</span>;

<span class="pl-k">use</span> <span class="pl-v">Sensio</span>\<span class="pl-v">Bundle</span>\<span class="pl-v">FrameworkExtraBundle</span>\<span class="pl-v">Configuration</span>\<span class="pl-v">Route</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Bundle</span>\<span class="pl-v">FrameworkBundle</span>\<span class="pl-v">Controller</span>\<span class="pl-v">AbstractController</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">HttpFoundation</span>\<span class="pl-v">Response</span>;

<span class="pl-k">class</span> <span class="pl-v">IndexController</span> <span class="pl-k">extends</span> <span class="pl-v">AbstractController</span>
{
    <span class="pl-c">/**</span>
<span class="pl-c">     * @Route(name="index")</span>
<span class="pl-c">     */</span>
    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">indexAction</span>(<span class="pl-smi"><span class="pl-smi">A</span></span> <span class="pl-s1"><span class="pl-c1">$</span>a</span>)
    {
        dump(<span class="pl-s1"><span class="pl-c1">$</span>a</span>);

        <span class="pl-k">return</span> <span class="pl-k">new</span> <span class="pl-v">Response</span>();
    }
}

<span class="pl-k">class</span> <span class="pl-v">A</span>
{
}</pre></div>
<p dir="auto">Expected result: an exception about wrong argument. Actual result:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/2552865/32139051-005f9c84-bc48-11e7-8088-e609a0b38ae8.png"><img src="https://user-images.githubusercontent.com/2552865/32139051-005f9c84-bc48-11e7-8088-e609a0b38ae8.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">Which means that a new instance of a non-DI class is injected.</p>
<p dir="auto">I investigated a little and found that <code class="notranslate">Symfony\Component\HttpKernel\Controller\ArgumentResolver\ServiceValueResolver</code> does this.</p>
<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>3.4</td>
</tr>
</tbody>
</table>
<p dir="auto">We're updating the Symfony Demo application to Symfony 3.4 (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="265492138" data-permission-text="Title is private" data-url="https://github.com/symfony/demo/issues/673" data-hovercard-type="pull_request" data-hovercard-url="/symfony/demo/pull/673/hovercard" href="https://github.com/symfony/demo/pull/673">symfony/demo#673</a>). Most of the triggered deprecations make sense, but we're struggling with this one:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/73419/31599863-75b4214c-b254-11e7-92a4-8f528b33de46.png"><img src="https://user-images.githubusercontent.com/73419/31599863-75b4214c-b254-11e7-92a4-8f528b33de46.png" alt="entity-deprecation" style="max-width: 100%;"></a></p>
<p dir="auto">Why does that deprecation occur? We even exclude the entire <code class="notranslate">Entity/</code> directory from autowiring:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    App\:
        resource: '../src/*'
        exclude: '../src/{DataFixtures,Entity,Repository,Tests}'"><pre class="notranslate">    <span class="pl-ent">App\</span>:
        <span class="pl-ent">resource</span>: <span class="pl-s"><span class="pl-pds">'</span>../src/*<span class="pl-pds">'</span></span>
        <span class="pl-ent">exclude</span>: <span class="pl-s"><span class="pl-pds">'</span>../src/{DataFixtures,Entity,Repository,Tests}<span class="pl-pds">'</span></span></pre></div>