Elastica\Aggregation\TopHits::toArray PHP Method

toArray() public method

public toArray ( ) : array
return array
    public function toArray()
    {
        $array = parent::toArray();
        // if there are no params, it's ok, but ES will throw exception if json
        // will be like {"top_hits":[]} instead of {"top_hits":{}}
        if (empty($array['top_hits'])) {
            $array['top_hits'] = new \stdClass();
        }
        return $array;
    }