src/Hydrator.php
public function recursiveConvertInArray($array)
    {
        $newArray = [];
        foreach ($array as $key => $value) {
            if ($value instanceof \MongoDB\Model\BSONDocument || $value instanceof \MongoDB\Model\BSONArray) {
                $value = (array) $value;
            }

            if (is_array($value)) {
                $value = $this->recursiveConvertInArray($value);
            }

            $newArray[$key] = $value;
        }

        return $newArray;
    }
public function recursiveConvertInArray($array)
    {
        $newArray = [];
        foreach ($array as $key => $value) {
            if ($value instanceof \MongoDB\Model\BSONDocument || $value instanceof \MongoDB\Model\BSONArray) {
                $value = (array) $value;
            }

            if (is_array($value)) {
                $value = $this->recursiveConvertInArray($value);
            }

            $newArray[$key] = $value;
        }

        return $newArray;
    }
public function recursiveConvertInArray ( $ array ) { $ newArray = [ ] ; foreach ( $ array as $ key => $ value ) { if ( $ value instanceof \ MongoDB \ Model \ BSONDocument || $ value instanceof \ MongoDB \ Model \ BSONArray ) { $ value = ( array ) $ value ; } if ( is_array ( $ value ) ) { $ value = $ this -> recursiveConvertInArray ( $ value ) ; } $ newArray [ $ key ] = $ value ; } return $ newArray ; }
Convert BSONDocument and BSONArray to array recursively

@param   array   $array  Array to convert
@return  array
Convert BSONDocument and BSONArray to array recursively