<p dir="auto">It seems in certain cases that a machine's environment will include an array.</p>
<p dir="auto">We seem to see this when using Assetic to compile a less file with the less compiler.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/*
[exception] 500 | Internal Server Error | ErrorException
[message] Notice: Array to string conversion in /[edited]/vendor/symfony/symfony/src/Symfony/Component/Process/Process.php line 141
[1] ErrorException: Notice: Array to string conversion in /[edited]/vendor/symfony/symfony/src/Symfony/Component/Process/Process.php line 141
                at n/a
                    in /[edited]/vendor/symfony/symfony/src/Symfony/Component/Process/Process.php line 141

                at Symfony\Component\HttpKernel\Debug\ErrorHandler-&amp;gt;handle(&amp;#039;8&amp;#039;, &amp;#039;Array to string conversion&amp;#039;"><pre class="notranslate"><code class="notranslate">/*
[exception] 500 | Internal Server Error | ErrorException
[message] Notice: Array to string conversion in /[edited]/vendor/symfony/symfony/src/Symfony/Component/Process/Process.php line 141
[1] ErrorException: Notice: Array to string conversion in /[edited]/vendor/symfony/symfony/src/Symfony/Component/Process/Process.php line 141
                at n/a
                    in /[edited]/vendor/symfony/symfony/src/Symfony/Component/Process/Process.php line 141

                at Symfony\Component\HttpKernel\Debug\ErrorHandler-&amp;gt;handle(&amp;#039;8&amp;#039;, &amp;#039;Array to string conversion&amp;#039;
</code></pre></div>
<p dir="auto">Offending line of code is here:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="            $this-&gt;env = array();
            foreach ($env as $key =&gt; $value) {
                $this-&gt;env[(binary) $key] = (binary) $value;
            }"><pre class="notranslate">            <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">env</span> = <span class="pl-en">array</span>();
            <span class="pl-k">foreach</span> (<span class="pl-s1"><span class="pl-c1">$</span>env</span> <span class="pl-k">as</span> <span class="pl-s1"><span class="pl-c1">$</span>key</span> =&gt; <span class="pl-s1"><span class="pl-c1">$</span>value</span>) {
                <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">env</span>[(<span class="pl-smi">binary</span>) <span class="pl-s1"><span class="pl-c1">$</span>key</span>] = (<span class="pl-smi">binary</span>) <span class="pl-s1"><span class="pl-c1">$</span>value</span>;
            }</pre></div>
<p dir="auto">The problem happens on the casting of $value to (binary).</p>
<p dir="auto">I'll try to submit a patch.</p>
<p dir="auto">(Note we were using Symfony 2.2, but it's probably in master as well)</p>
<p dir="auto">Line 138-142 of Process.php:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="        if (null !== $env) {
            $this-&gt;env = array();
            foreach ($env as $key =&gt; $value) {
                $this-&gt;env[(binary) $key] = (binary) $value;
            }"><pre class="notranslate">        <span class="pl-k">if</span> (<span class="pl-c1">null</span> !== <span class="pl-s1"><span class="pl-c1">$</span>env</span>) {
            <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">env</span> = <span class="pl-en">array</span>();
            <span class="pl-k">foreach</span> (<span class="pl-s1"><span class="pl-c1">$</span>env</span> <span class="pl-k">as</span> <span class="pl-s1"><span class="pl-c1">$</span>key</span> =&gt; <span class="pl-s1"><span class="pl-c1">$</span>value</span>) {
                <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">env</span>[(<span class="pl-smi">binary</span>) <span class="pl-s1"><span class="pl-c1">$</span>key</span>] = (<span class="pl-smi">binary</span>) <span class="pl-s1"><span class="pl-c1">$</span>value</span>;
            }</pre></div>
<p dir="auto">In certain circumstances, ProcessBuilder.php will grab $_ENV and merge it into the array passed into Process.php</p>
<p dir="auto">ProcessBuilder.php line 148-154:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="        if ($this-&gt;inheritEnv) {
            $env = $this-&gt;env ? $this-&gt;env + $_ENV : null;
        } else {
            $env = $this-&gt;env;
        }

        return new Process($script, $this-&gt;cwd, $env, $this-&gt;stdin, $this-&gt;timeout, $options);"><pre class="notranslate">        <span class="pl-k">if</span> (<span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">inheritEnv</span>) {
            <span class="pl-s1"><span class="pl-c1">$</span>env</span> = <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">env</span> ? <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">env</span> + <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-c1">_ENV</span></span> : <span class="pl-c1">null</span>;
        } <span class="pl-k">else</span> {
            <span class="pl-s1"><span class="pl-c1">$</span>env</span> = <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">env</span>;
        }

        <span class="pl-k">return</span> <span class="pl-k">new</span> <span class="pl-v">Process</span>(<span class="pl-s1"><span class="pl-c1">$</span>script</span>, <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">cwd</span>, <span class="pl-s1"><span class="pl-c1">$</span>env</span>, <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">stdin</span>, <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">timeout</span>, <span class="pl-s1"><span class="pl-c1">$</span>options</span>);</pre></div>
<p dir="auto">The problem is that there are certain cases where $_ENV['something'] can be an array.</p>
<p dir="auto">Right now in one of our environments, I'm seeing $_ENV['argv'] as an array, for example.  This happens during Less to CSS generation.</p>