Skip to content

Commit 42f5bfb

Browse files
committed
Merge branch '2.x'
* 2.x: feature #894 Show user by ID (genintho) Don't urlencode integer values Fixed incorrect MissingArgumentException parent constructor values Removed shadow-cat minor #892 Don't use deprecated auth in examples (GrahamCampbell) Fix broken roave/bc-check test Update branch alias
2 parents 7684011 + 1c16592 commit 42f5bfb

30 files changed

+161
-126
lines changed

.github/bc-test.sh

Lines changed: 0 additions & 49 deletions
This file was deleted.

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ php:
1818

1919
matrix:
2020
include:
21-
- php: 7.2
21+
- php: 7.4.7
2222
name: Backward compatibillity check
23-
env: DEPENDENCIES="roave/backward-compatibility-check" TEST_COMMAND="./.github/bc-test.sh"
23+
env: DEPENDENCIES="roave/backward-compatibility-check" TEST_COMMAND="vendor/bin/roave-backward-compatibility-check"
2424
- php: 7.4
2525
name: phpstan
2626
script:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"prefer-stable": true,
4545
"extra": {
4646
"branch-alias": {
47-
"dev-master": "3.0.x-dev"
47+
"dev-2.x": "3.0.x-dev"
4848
}
4949
}
5050
}

doc/currentuser/repositories.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ There are three values that can be passed into the `repositories` method: `type`
2525

2626
```php
2727
$client = new \Github\Client();
28-
$client->authenticate($github_token, null, \Github\Client::AUTH_HTTP_TOKEN);
28+
$client->authenticate($github_token, null, \Github\Client::AUTH_ACCESS_TOKEN);
2929
$client->currentUser()->repositories();
3030
```

doc/security.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ Note however that GitHub describes this method as deprecated. In most case you s
5151
### Authenticating as an Integration
5252

5353
To authenticate as an integration you need to supply a JSON Web Token with `Github\Client::AUTH_JWT` to request
54-
and installation access token which is then usable with `Github\Client::AUTH_HTTP_TOKEN`. [Github´s integration
54+
and installation access token which is then usable with `Github\Client::AUTH_ACCESS_TOKEN`. [Github´s integration
5555
authentication docs](https://developer.github.com/apps/building-github-apps/authentication-options-for-github-apps/#authenticating-as-a-github-app) describe the flow in detail.
5656
It´s important for integration requests to use the custom Accept header `application/vnd.github.machine-man-preview`.
5757

58-
The following sample code authenticates as an installation using [lcobucci/jwt](https://github.com/lcobucci/jwt/tree/3.2.0)
58+
The following sample code authenticates as an installation using [lcobucci/jwt](https://github.com/lcobucci/jwt/tree/3.3.2)
5959
to generate a JSON Web Token (JWT).
6060

6161
```php
@@ -78,7 +78,7 @@ $jwt = (new Builder)
7878
$github->authenticate($jwt, null, Github\Client::AUTH_JWT);
7979

8080
$token = $github->api('apps')->createInstallationToken($installationId);
81-
$github->authenticate($token['token'], null, Github\Client::AUTH_HTTP_TOKEN);
81+
$github->authenticate($token['token'], null, Github\Client::AUTH_ACCESS_TOKEN);
8282
```
8383

8484
The `$integrationId` you can find in the about section of your github app.

doc/users.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ $user = $client->api('user')->show('KnpLabs');
3636

3737
Returns an array of information about the user.
3838

39+
40+
You can also use the User ID, but it will use an undocumented Github API
41+
42+
```php
43+
$user = $client->api('user')->showById(202732);
44+
```
45+
3946
### Update user information
4047

4148
> Requires [authentication](security.md).

lib/Github/Api/Apps.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function createInstallationToken($installationId, $userId = null)
3636

3737
$this->configurePreviewHeader();
3838

39-
return $this->post('/app/installations/'.rawurlencode($installationId).'/access_tokens', $parameters);
39+
return $this->post('/app/installations/'.$installationId.'/access_tokens', $parameters);
4040
}
4141

4242
/**
@@ -66,7 +66,7 @@ public function getInstallation($installationId)
6666
{
6767
$this->configurePreviewHeader();
6868

69-
return $this->get('/app/installations/'.rawurldecode($installationId));
69+
return $this->get('/app/installations/'.$installationId);
7070
}
7171

7272
/**
@@ -129,7 +129,7 @@ public function removeInstallation($installationId)
129129
{
130130
$this->configurePreviewHeader();
131131

132-
$this->delete('/app/installations/'.rawurldecode($installationId));
132+
$this->delete('/app/installations/'.$installationId);
133133
}
134134

135135
/**
@@ -167,7 +167,7 @@ public function addRepository($installationId, $repositoryId)
167167
{
168168
$this->configurePreviewHeader();
169169

170-
return $this->put('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId));
170+
return $this->put('/installations/'.$installationId.'/repositories/'.$repositoryId);
171171
}
172172

173173
/**
@@ -184,6 +184,6 @@ public function removeRepository($installationId, $repositoryId)
184184
{
185185
$this->configurePreviewHeader();
186186

187-
return $this->delete('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId));
187+
return $this->delete('/installations/'.$installationId.'/repositories/'.$repositoryId);
188188
}
189189
}

lib/Github/Api/CurrentUser/Notifications.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function markAsReadInRepository($username, $repository, array $params = [
8383
*/
8484
public function markAsRead($id, array $params)
8585
{
86-
return $this->patch('/notifications/threads/'.rawurlencode($id), $params);
86+
return $this->patch('/notifications/threads/'.$id, $params);
8787
}
8888

8989
/**
@@ -97,7 +97,7 @@ public function markAsRead($id, array $params)
9797
*/
9898
public function show($id)
9999
{
100-
return $this->get('/notifications/threads/'.rawurlencode($id));
100+
return $this->get('/notifications/threads/'.$id);
101101
}
102102

103103
/**
@@ -111,7 +111,7 @@ public function show($id)
111111
*/
112112
public function showSubscription($id)
113113
{
114-
return $this->get('/notifications/threads/'.rawurlencode($id).'/subscription');
114+
return $this->get('/notifications/threads/'.$id.'/subscription');
115115
}
116116

117117
/**
@@ -126,7 +126,7 @@ public function showSubscription($id)
126126
*/
127127
public function createSubscription($id, array $params)
128128
{
129-
return $this->put('/notifications/threads/'.rawurlencode($id).'/subscription', $params);
129+
return $this->put('/notifications/threads/'.$id.'/subscription', $params);
130130
}
131131

132132
/**
@@ -140,6 +140,6 @@ public function createSubscription($id, array $params)
140140
*/
141141
public function removeSubscription($id)
142142
{
143-
return $this->delete('/notifications/threads/'.rawurlencode($id).'/subscription');
143+
return $this->delete('/notifications/threads/'.$id.'/subscription');
144144
}
145145
}

lib/Github/Api/CurrentUser/PublicKeys.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function all()
3535
*/
3636
public function show($id)
3737
{
38-
return $this->get('/user/keys/'.rawurlencode($id));
38+
return $this->get('/user/keys/'.$id);
3939
}
4040

4141
/**
@@ -69,6 +69,6 @@ public function create(array $params)
6969
*/
7070
public function remove($id)
7171
{
72-
return $this->delete('/user/keys/'.rawurlencode($id));
72+
return $this->delete('/user/keys/'.$id);
7373
}
7474
}

lib/Github/Api/Deployment.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function all($username, $repository, array $params = [])
3838
*/
3939
public function show($username, $repository, $id)
4040
{
41-
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.rawurlencode($id));
41+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id);
4242
}
4343

4444
/**
@@ -88,7 +88,7 @@ public function updateStatus($username, $repository, $id, array $params)
8888
throw new MissingArgumentException(['state']);
8989
}
9090

91-
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.rawurlencode($id).'/statuses', $params);
91+
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses', $params);
9292
}
9393

9494
/**
@@ -102,6 +102,6 @@ public function updateStatus($username, $repository, $id, array $params)
102102
*/
103103
public function getStatuses($username, $repository, $id)
104104
{
105-
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.rawurlencode($id).'/statuses');
105+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses');
106106
}
107107
}

lib/Github/Api/Gist/Comments.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function all($gist)
5656
*/
5757
public function show($gist, $comment)
5858
{
59-
return $this->get('/gists/'.rawurlencode($gist).'/comments/'.rawurlencode($comment));
59+
return $this->get('/gists/'.rawurlencode($gist).'/comments/'.$comment);
6060
}
6161

6262
/**
@@ -83,7 +83,7 @@ public function create($gist, $body)
8383
*/
8484
public function update($gist, $comment_id, $body)
8585
{
86-
return $this->patch('/gists/'.rawurlencode($gist).'/comments/'.rawurlencode($comment_id), ['body' => $body]);
86+
return $this->patch('/gists/'.rawurlencode($gist).'/comments/'.$comment_id, ['body' => $body]);
8787
}
8888

8989
/**
@@ -96,6 +96,6 @@ public function update($gist, $comment_id, $body)
9696
*/
9797
public function remove($gist, $comment)
9898
{
99-
return $this->delete('/gists/'.rawurlencode($gist).'/comments/'.rawurlencode($comment));
99+
return $this->delete('/gists/'.rawurlencode($gist).'/comments/'.$comment);
100100
}
101101
}

lib/Github/Api/Gists.php

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public function configure($bodyType = null)
3737
return $this;
3838
}
3939

40+
/**
41+
* @param string|null $type
42+
*
43+
* @return array|string
44+
*/
4045
public function all($type = null)
4146
{
4247
if (!in_array($type, ['public', 'starred'])) {
@@ -46,6 +51,11 @@ public function all($type = null)
4651
return $this->get('/gists/'.rawurlencode($type));
4752
}
4853

54+
/**
55+
* @param string $number
56+
*
57+
* @return array
58+
*/
4959
public function show($number)
5060
{
5161
return $this->get('/gists/'.rawurlencode($number));
@@ -54,7 +64,7 @@ public function show($number)
5464
/**
5565
* Get a specific revision of a gist.
5666
*
57-
* @param int $number
67+
* @param string $number
5868
* @param string $sha
5969
*
6070
* @link https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
@@ -77,41 +87,82 @@ public function create(array $params)
7787
return $this->post('/gists', $params);
7888
}
7989

90+
/**
91+
* @param string $id
92+
* @param array $params
93+
*
94+
* @return array
95+
*/
8096
public function update($id, array $params)
8197
{
8298
return $this->patch('/gists/'.rawurlencode($id), $params);
8399
}
84100

101+
/**
102+
* @param string $id
103+
*
104+
* @return array
105+
*/
85106
public function commits($id)
86107
{
87108
return $this->get('/gists/'.rawurlencode($id).'/commits');
88109
}
89110

111+
/**
112+
* @param string $id
113+
*
114+
* @return array
115+
*/
90116
public function fork($id)
91117
{
92118
return $this->post('/gists/'.rawurlencode($id).'/fork');
93119
}
94120

121+
/**
122+
* @param string $id
123+
*
124+
* @return array
125+
*/
95126
public function forks($id)
96127
{
97128
return $this->get('/gists/'.rawurlencode($id).'/forks');
98129
}
99130

131+
/**
132+
* @param string $id
133+
*
134+
* @return array
135+
*/
100136
public function remove($id)
101137
{
102138
return $this->delete('/gists/'.rawurlencode($id));
103139
}
104140

141+
/**
142+
* @param string $id
143+
*
144+
* @return array
145+
*/
105146
public function check($id)
106147
{
107148
return $this->get('/gists/'.rawurlencode($id).'/star');
108149
}
109150

151+
/**
152+
* @param string $id
153+
*
154+
* @return array
155+
*/
110156
public function star($id)
111157
{
112158
return $this->put('/gists/'.rawurlencode($id).'/star');
113159
}
114160

161+
/**
162+
* @param string $id
163+
*
164+
* @return array
165+
*/
115166
public function unstar($id)
116167
{
117168
return $this->delete('/gists/'.rawurlencode($id).'/star');

0 commit comments

Comments
 (0)