Skip to content

ResultPager::fetchAll() doesn't work with the search API #253

@parhamdoustdar

Description

@parhamdoustdar

THis piece of code returns only 4 results:

        $searchString = "location:Tehran language:php";
        $pager = new ResultPager($this->client);

        return $pager->fetchAll($this->client->search(), 'users', [$searchString]);

The reason this is happening is the use of array_merge() on line 78 of ResultPager:

$result = array_merge($result, $this->fetchNext());

Since the search results are put in the items key of the returned result, it gets overridden using array_merge(). I unfortunately do not know enough about the GitHub API results to suggest an improvement, but maybe adding an optional argument to ResultPager::fetchAll() that would be the key that needs to be merged might help. For example, my call would look like this:

return $pager->fetchAll($this->client->search(), 'users', [$searchString], 'items');

One other thing that could help is to override values if they are not arrays, and merge them if they are.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions