<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.3.x-dev</td>
</tr>
</tbody>
</table>
<p dir="auto">A few weeks ago on master I was able to use <code class="notranslate">factory</code> in my <code class="notranslate">_instanceof</code> Yaml service declarations. This was useful because all instances of DoctrineRepository need the same factory call. Without it, all DoctrineRepositories have to duplicate the same factory line. The purpose of <code class="notranslate">_instanceof</code> to reduce duplication would be better served if we could use factory.</p>
<p dir="auto"><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> I edited <code class="notranslate">DependencyInjection/Loader/YamlFileLoader</code> and added <code class="notranslate">'factory' =&gt; 'factory'</code> to the <code class="notranslate">$instanceofKeywords</code> array and it seemed to work. Any drawbacks? Better solutions?</p>
<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>no</td>
</tr>
<tr>
<td>Feature request?</td>
<td>yes</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>master</td>
</tr>
</tbody>
</table>
<p dir="auto">Following up on <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="216725633" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/22143" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/22143/hovercard" href="https://github.com/symfony/symfony/issues/22143">#22143</a>, the lack of proper error is solved now in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="217325433" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/22185" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/22185/hovercard" href="https://github.com/symfony/symfony/pull/22185">#22185</a>, but the use case for <code class="notranslate">factory</code> still seems valid:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="services:
    _defaults:
        factory:        [ &quot;@doctrine&quot;, getRepository ]

    AppBundle\RoleRepository:
        arguments:      [ &quot;AppBundle:Role&quot; ]
    AppBundle\UserRepository:
        arguments:      [ &quot;AppBundle:User&quot; ]"><pre class="notranslate"><span class="pl-ent">services</span>:
    <span class="pl-ent">_defaults</span>:
        <span class="pl-ent">factory</span>:        <span class="pl-s">[ "@doctrine", getRepository ]</span>

    <span class="pl-ent">AppBundle\RoleRepository</span>:
        <span class="pl-ent">arguments</span>:      <span class="pl-s">[ "AppBundle:Role" ]</span>
    <span class="pl-ent">AppBundle\UserRepository</span>:
        <span class="pl-ent">arguments</span>:      <span class="pl-s">[ "AppBundle:User" ]</span></pre></div>
<p dir="auto">It was decided in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="197736884" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/21071" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/21071/hovercard?comment_id=94062689&amp;comment_type=review_comment" href="https://github.com/symfony/symfony/pull/21071#discussion_r94062689">#21071 (comment)</a> to consider the <code class="notranslate">factory</code> attribute a detector flag for real services, but this <a href="https://github.com/symfony/symfony/pull/22185" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/22185/hovercard">has become obsolete</a>, and the use case for <a href="https://github.com/symfony/symfony/pull/21071#issuecomment-269835047" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/21071/hovercard">default factory settings is there</a>.</p>
<p dir="auto">Therefore I propose to reallow <code class="notranslate">factory</code> in <code class="notranslate">_defaults</code> sections.</p>