<p dir="auto">To recreate, add the following to <code class="notranslate">config.yml</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="twig:
    globals:
        foo: &quot;@@bar&quot;"><pre class="notranslate"><code class="notranslate">twig:
    globals:
        foo: "@@bar"
</code></pre></div>
<p dir="auto"><strong>Expected behaviour:</strong> Twig has a global variable named <code class="notranslate">foo</code> containing the string <code class="notranslate">@bar</code>.</p>
<p dir="auto"><strong>Actual behaviour:</strong> ServiceNotFoundException: The service "twig" has a dependency on a non-existent service "<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/bar/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/bar">@bar</a>".</p>
<p dir="auto">Environment tested on:</p>
<ul dir="auto">
<li>Symfony Standard Distribution 2.3.2</li>
<li>OS X 10.8.4</li>
<li>PHP 5.4.16</li>
</ul>
<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>yes</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>3.4.x</td>
</tr>
</tbody>
</table>
<p dir="auto">I have a project that depends on symfony/http-foundation. With 3.4.x-dev I'm getting some RuntimeErrors recently:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="RuntimeException: Failed to set the session handler because headers have already been sent
by &quot;.../vendor/phpunit/phpunit/src/Util/Printer.php&quot; at line 110.

.../vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:397
.../vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:112
.../classes/Http/SessionProvider.php:128
.../vendor/autarky/container/classes/Factory/Factory.php:89
.../vendor/autarky/container/classes/Container.php:256
.../vendor/autarky/container/classes/Container.php:226
.../classes/Application.php:511
.../tests/unit/Session/SessionProviderTest.php:20"><pre class="notranslate"><code class="notranslate">RuntimeException: Failed to set the session handler because headers have already been sent
by ".../vendor/phpunit/phpunit/src/Util/Printer.php" at line 110.

.../vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:397
.../vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:112
.../classes/Http/SessionProvider.php:128
.../vendor/autarky/container/classes/Factory/Factory.php:89
.../vendor/autarky/container/classes/Container.php:256
.../vendor/autarky/container/classes/Container.php:226
.../classes/Application.php:511
.../tests/unit/Session/SessionProviderTest.php:20
</code></pre></div>
<p dir="auto">I tracked down the line to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="246510573" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/23711" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/23711/hovercard" href="https://github.com/symfony/symfony/pull/23711">#23711</a> which was merged 2 days ago. If I remove the if headers_sent thing from setSaveHandler, my test runs fine again.</p>
<p dir="auto">PHPUnit 5.7.22, symfony/http-foundation is at <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/symfony/symfony/commit/0fe9b3dc9902a89e646ca5bf053690018830999b/hovercard" href="https://github.com/symfony/symfony/commit/0fe9b3dc9902a89e646ca5bf053690018830999b"><tt>0fe9b3d</tt></a></p>