Skip to content

Commit

Permalink
Fix type error in ResultPager::fetch
Browse files Browse the repository at this point in the history
When using etags, the reply from github may be empty and the underlying APIs will return an empty string.
We need to flip those to empty arrays.
e.g.:
```
$github_builder
  ->addPlugin(new Http\Client\Common\Plugin\HeaderSetPlugin([
    'If-None-Match' => $etag,
  ]));

$api       = $github_client->user('user');
$paginator = new \Github\ResultPager($github_client);
$data      = $paginator->fetch($api, 'events', [$username]);
// $data should be [] if $etag is the latest
```
  • Loading branch information
nunoplopes authored Mar 3, 2024
1 parent 9afaf87 commit 7fc5507
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Github/ResultPager.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function fetch(AbstractApi $api, string $method, array $parameters = []):

$this->postFetch(true);

return $result;
return $result ? $result : [];
}

/**
Expand Down

0 comments on commit 7fc5507

Please sign in to comment.