title: PHP MongoDB aggregation returns empty
body: <p>I'm trying to implement an average calculation over a mongo dataset using <code>MongoCollection()::aggregate()</code>, but the functions returns a Cursor object and I can't figure out what I'm doing wrong.</p>
  
  <p>This a sample of the dataset content:</p>
  
  <pre><code>{ word : "word", time : 1234, result  : "pass" }
  </code></pre>
  
  <p>This pipeline query works in the mongo console:</p>
  
  <pre><code>{"$group" : 
     {"_id" : "$result", 
      "meanTime" : {"$avg" :"$time"}
     }
  }
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>    public function  getTimes($fields = array('correct','wrong','pass')){
  
  
      $group = ['$group'=&gt; ["_id" =&gt; '$result', "meanTime" =&gt; ['$avg' =&gt;'$time']]];
  
      $agg = $this-&gt;collection-&gt;aggregate(
                      [$group]
                      );
      return $agg;
  
  }
  /*
  //This is the var_dump on $agg
  object(MongoDB\Driver\Cursor)#82 (2) {
  ["cursor"]=&gt;
  array(17) {
  ["stamp"]=&gt;
  int(0)
  ["is_command"]=&gt;
  bool(false)
  ["sent"]=&gt;
  bool(true)
  ["done"]=&gt;
  bool(false)
  ["end_of_event"]=&gt;
  bool(false)
  ["in_exhaust"]=&gt;
  bool(false)
  ["has_fields"]=&gt;
  bool(false)
  ["query"]=&gt;
  object(stdClass)#76 (0) {
  }
  ["fields"]=&gt;
      object(stdClass)#74 (0) {
      }
      ["read_preference"]=&gt;
      array(2) {
      ["mode"]=&gt;
        int(1)
        ["tags"]=&gt;
        array(0) {
      }
      }
      ["flags"]=&gt;
      int(0)
      ["skip"]=&gt;
      int(0)
      ["limit"]=&gt;
      int(0)
      ["count"]=&gt;
      int(2)
      ["batch_size"]=&gt;
      int(0)
      ["ns"]=&gt;
      string(23) "circular.intesavincente"
  ["current_doc"]=&gt;
      object(stdClass)#83 (2) {
      ["_id"]=&gt;
        string(4) "pass"
  ["meanTime"]=&gt;
        float(338)
      }
    }
    ["server_id"]=&gt;
    int(1)
  }
  
  //This is the json_encode output
  {}
  
  */
  </code></pre>
  
  <p>I have tried to write the pipeline array with both <code>array()</code> construct and simplified <code>[]</code>, but the result is unchanged. What I'm doing wrong? Thanks</p>