Elastica\Query\InnerHits::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['inner_hits'])) {
            $array['inner_hits'] = new \stdClass();
        }
        return $array['inner_hits'];
    }