tan-tan-kanarek / github-php-client

MIT License
184 stars 120 forks source link

Implemented assigning multiple assignees to an issue #112

Closed eXistenZNL closed 8 years ago

eXistenZNL commented 8 years ago

What has been done

As per May 27th of 2016 Github announced that it's possible to assign multiple assignees via their API.

This PR implements that.

Why

I use this library in PRBot and now had to resort to a custom API call via $client->request() in order to make use of the new API and assign multiple assignees.

How to test

Create GitHub client, and edit an issue on a repo likes so:

<?php

ini_set('display_errors', true);
ini_set('error_reporting', E_ALL);

require_once(__DIR__ . '/client/GitHubClient.php');

$client = new GitHubClient();

$client->setAuthType(GitHubClient::GITHUB_AUTH_TYPE_OAUTH_BASIC);
$client->setOauthKey('your-oauth-token');

$issue = $client->issues->editAnIssue(
    'SomeFork',
    'SomeRepo',
    null,
    123,
    null,
    ['tan-tan-kanarek', 'eXistenZNL']
);

This works, and for backwards compatibility reasons supplying a string also works:

$issue = $client->issues->editAnIssue(
    'SomeFork',
    'SomeRepo',
    null,
    123,
    null,
    'tan-tan-kanarek'
);

but in this case a warning will be shown of level E_USER_DEPRECATED:

$ php test.php
PHP Deprecated:  Supplying a string is deprecated, please supply an array of strings. in /projects/github-php-client/client/services/GitHubIssues.php on line 219

Some other things

I changed GitHubIssues::editAnIssue() so that $title is no longer mandatory. To prevent backwards compatibility breakage I did not change the order of the arguments, but this sadly means that you now have to supply null as an argument twice.

This could be improved by moving the mandatory arguments to the left and the arguments that may be omited to the right, but would require releasing a new major version.

Questions and remarks

Just contact me, you know where to find me (-:

tan-tan-kanarek commented 8 years ago

Thank you.