<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>4-beta2</td>
</tr>
</tbody>
</table>
<p dir="auto">When using .env in config, the casting is not work.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Invalid type for path &quot;easy_admin.list.max_results&quot;. Expected int, but got string."><pre class="notranslate"><code class="notranslate">Invalid type for path "easy_admin.list.max_results". Expected int, but got string.
</code></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/7464920/32268190-97b6ae3a-bf20-11e7-8990-79732b14bee3.png"><img src="https://user-images.githubusercontent.com/7464920/32268190-97b6ae3a-bf20-11e7-8990-79732b14bee3.png" alt="screenshot from 2017-11-01 16-19-53" style="max-width: 100%;"></a></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>3.2</td>
</tr>
</tbody>
</table>
<p dir="auto">Related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="187725091" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/20434" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/20434/hovercard" href="https://github.com/symfony/symfony/issues/20434">#20434</a>, if you try to pull data such as CACHE from an environment variable and pass it to Twig, Twig's Bundle reads the type literally, as "false" or "true" - as it is passed from <code class="notranslate">getenv</code>.</p>
<h2 dir="auto">How to Replicate</h2>
<p dir="auto">Add this environment variable:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="CACHE false"><pre class="notranslate"><code class="notranslate">CACHE false
</code></pre></div>
<p dir="auto">In config.yml:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="twig:
    cache: %env(CACHE)%"><pre class="notranslate"><code class="notranslate">twig:
    cache: %env(CACHE)%
</code></pre></div>
<p dir="auto">This results in a cache being created under <code class="notranslate">web/false/</code>, which is certainly not the intended result.</p>
<p dir="auto">Note that this has other unintended consequences throughout Symfony, where a boolean is expected but not validated.</p>
<h2 dir="auto">Solutions?</h2>
<p dir="auto">A simple solution could be to use the <code class="notranslate">env()</code> library created by Laravel as it provides for type coercion out of the box.</p>