Why would PHP::max(array) result in an empty-array-warning if the array is not actually empty?
<p><strong>[Closure Update]</strong></p>

<p>Shortly after asking this question my team had decided that i simply re-setup the entire project on my machine (we sometimes try to use democracy). This resulted in everything working as expected. But i would still like to know from anyone why this had happened? :D</p>

<p>I have also started working with a new employer, so i will not have access to the same machine and project any longer, unfortunately.</p>

<p><strong>[/End Update]</strong></p>

<p>Not entirely sure how to explain/ask this...</p>

<p>I generate an array and populate it using array_push() to add content i get from Symfony2 database queries. 
Currently the array result contains two elements with both values being "80". If i check the content and length of the array then all checks out; its a two element array ( var_dump() is_array() etc ).</p>

<p>When i use this array in max() then i get the warning "Warning: max(): Array must contain at least one element..".</p>

<p>If i alter the array immediately before passing it to max(), by manually changing the two elements in the array to the same values:</p>

<pre><code>$theArray[0]= "80";
$theArray[1]= "80";
</code></pre>

<p>Then max is happy!
If i do a var dump of the array after generation and after me editing it (before max) both are the same:</p>

<pre><code>array(2) { [0]=&gt; string(2) "80" [1]=&gt; string(2) "80" }
array(2) { [0]=&gt; string(2) "80" [1]=&gt; string(2) "80" }
</code></pre>

<p>And thus i ask if anyone knows why would max() give an empty array warning on an array that is not actually empty? o.O</p>

<p><strong>EDIT</strong> (per request)
Part of function that actually uses the array in max etc. The snippit is what results in the similar var_dump results, as explained above. </p>

<pre><code>    private function _functionName(&amp;$param1, &amp;$param2, $instrumentAggregates, $param3)
    {
        var_dump($instrumentAggregates);

        $instrumentAggregates[0]= "80";
        $instrumentAggregates[1]= "80";
        var_dump($instrumentAggregates);
        //exit();

        $statusCode= max($instrumentAggregates);
        ...
    }
</code></pre>

<p><strong>EDIT 2</strong> (per request) A snippet of the function which creates and returns the array which is used in the above snippet.Doing a var dump on the array before it is returned has the same result as shown earlier in the question description.</p>

<pre><code>private function _functionName(&amp;$param1, &amp;$participantAssessmentRepository, $participant, $param4)
{
    $participantId= (string)$participant-&gt;getId();
    $projectAssesmentList= $participantAssessmentRepository-&gt;findAssessmentByParticipantId( $participantId );                                                
    $instrumentAggregates= array();
    ...        
    foreach($projectAssesmentList as $projectAssesment) {
        ...
        array_push($instrumentAggregates, $projectAssesment-&gt;getStatus()-&gt;getCode());            
        ...
    }
    return $instrumentAggregates;
}
</code></pre>

<p><strong>EDIT 3</strong> The final straw. Here follows a change in the first function, of this question, which apparently bypasses the issue. No idea if this would mean anything to anyone but i am giving up and using this work around for now.</p>

<pre><code>...
$inst1= $instrumentAggregates[0];
$inst2= $instrumentAggregates[1];

$instrumentAggregates[0]= $inst1;
$instrumentAggregates[1]= $inst2;
...
</code></pre>

<p>Using the array in max() then works just fine! Because i expect the above array to be of any length i will change the above to be a for each (hopefully that still works). But still i do not understand what the issue could be?
Perhaps it's just a typical "I can't do that Dave" from my PC..</p>

<p>Thank you,</p>
