From 624da985f19883e5a64f554f1fc06f2a2e5c43c2 Mon Sep 17 00:00:00 2001 From: Vasilis Lolos Date: Mon, 13 Apr 2020 18:48:14 +0300 Subject: [PATCH 1/8] Ignore PHPStorm's .idea directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ebe7b7ea7a3..d244324f4d7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ phpunit.xml composer.lock composer.phar vendor/* +.idea/* From 3f332edcd4014cccdd9c5b8500c84564dc5dda53 Mon Sep 17 00:00:00 2001 From: Vasilis Lolos Date: Mon, 13 Apr 2020 19:52:07 +0300 Subject: [PATCH 2/8] Fix various Teams' URIs - \Github\Api\Organization\Teams::show - \Github\Api\Organization\Teams::update - \Github\Api\Organization\Teams::remove - \Github\Api\Organization\Teams::members - \Github\Api\Organization\Teams::check - \Github\Api\Organization\Teams::addMember - \Github\Api\Organization\Teams::removeMember --- lib/Github/Api/Organization/Teams.php | 49 +++++++++++++------ .../Tests/Api/Organization/TeamsTest.php | 34 ++++++------- 2 files changed, 52 insertions(+), 31 deletions(-) diff --git a/lib/Github/Api/Organization/Teams.php b/lib/Github/Api/Organization/Teams.php index 401dbe4f116..00b57758b05 100644 --- a/lib/Github/Api/Organization/Teams.php +++ b/lib/Github/Api/Organization/Teams.php @@ -32,12 +32,18 @@ public function create($organization, array $params) return $this->post('/orgs/'.rawurlencode($organization).'/teams', $params); } - public function show($team) + /** + * @link https://developer.github.com/v3/teams/#list-teams + */ + public function show($team, $organization) { - return $this->get('/teams/'.rawurlencode($team)); + return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team)); } - public function update($team, array $params) + /** + * @link https://developer.github.com/v3/teams/#edit-team + */ + public function update($team, array $params, $organization) { if (!isset($params['name'])) { throw new MissingArgumentException('name'); @@ -46,32 +52,47 @@ public function update($team, array $params) $params['permission'] = 'pull'; } - return $this->patch('/teams/'.rawurlencode($team), $params); + return $this->patch('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team), $params); } - public function remove($team) + /** + * @link https://developer.github.com/v3/teams/#delete-team + */ + public function remove($team, $organization) { - return $this->delete('/teams/'.rawurlencode($team)); + return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team)); } - public function members($team) + /** + * @link https://developer.github.com/v3/teams/members/#list-team-members + */ + public function members($team, $organization) { - return $this->get('/teams/'.rawurlencode($team).'/members'); + return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/members'); } - public function check($team, $username) + /** + * @link https://developer.github.com/v3/teams/members/#get-team-membership + */ + public function check($team, $username, $organization) { - return $this->get('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); + return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } - public function addMember($team, $username) + /** + * @link https://developer.github.com/v3/teams/members/#add-or-update-team-membership + */ + public function addMember($team, $username, $organization) { - return $this->put('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); + return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } - public function removeMember($team, $username) + /** + * @link https://developer.github.com/v3/teams/members/#remove-team-membership + */ + public function removeMember($team, $username, $organization) { - return $this->delete('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); + return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } public function repositories($team) diff --git a/test/Github/Tests/Api/Organization/TeamsTest.php b/test/Github/Tests/Api/Organization/TeamsTest.php index 3c5474181e7..3538113ad61 100644 --- a/test/Github/Tests/Api/Organization/TeamsTest.php +++ b/test/Github/Tests/Api/Organization/TeamsTest.php @@ -33,10 +33,10 @@ public function shouldCheckIfMemberIsInOrganizationTeam() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/teams/KnpWorld/memberships/l3l0') + ->with('/orgs/KnpLabs/teams/KnpWorld/memberships/l3l0') ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->check('KnpWorld', 'l3l0')); + $this->assertEquals($expectedValue, $api->check('KnpWorld', 'l3l0', 'KnpLabs')); } /** @@ -49,10 +49,10 @@ public function shouldRemoveOrganizationTeam() $api = $this->getApiMock(); $api->expects($this->once()) ->method('delete') - ->with('/teams/KnpWorld') + ->with('/orgs/KnpLabs/teams/KnpWorld') ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->remove('KnpWorld')); + $this->assertEquals($expectedValue, $api->remove('KnpWorld', 'KnpLabs')); } /** @@ -65,10 +65,10 @@ public function shouldShowOrganizationTeam() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/teams/KnpWorld') + ->with('/orgs/KnpLabs/teams/KnpWorld') ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->show('KnpWorld')); + $this->assertEquals($expectedValue, $api->show('KnpWorld', 'KnpLabs')); } /** @@ -81,10 +81,10 @@ public function shouldGetTeamMembers() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/teams/KnpWorld/members') + ->with('/orgs/KnpLabs/teams/KnpWorld/members') ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->members('KnpWorld')); + $this->assertEquals($expectedValue, $api->members('KnpWorld', 'KnpLabs')); } /** @@ -97,10 +97,10 @@ public function shouldAddTeamMembers() $api = $this->getApiMock(); $api->expects($this->once()) ->method('put') - ->with('/teams/KnpWorld/memberships/l3l0') + ->with('/orgs/KnpLabs/teams/KnpWorld/memberships/l3l0') ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->addMember('KnpWorld', 'l3l0')); + $this->assertEquals($expectedValue, $api->addMember('KnpWorld', 'l3l0', 'KnpLabs')); } /** @@ -113,10 +113,10 @@ public function shouldRemoveTeamMembers() $api = $this->getApiMock(); $api->expects($this->once()) ->method('delete') - ->with('/teams/KnpWorld/memberships/l3l0') + ->with('/orgs/KnpLabs/teams/KnpWorld/memberships/l3l0') ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->removeMember('KnpWorld', 'l3l0')); + $this->assertEquals($expectedValue, $api->removeMember('KnpWorld', 'l3l0', 'KnpLabs')); } /** @@ -261,7 +261,7 @@ public function shouldNotUpdateTeamWithoutName() $api->expects($this->never()) ->method('patch'); - $api->update('KnpWorld', $data); + $api->update('KnpWorld', $data, 'KnpLabs'); } /** @@ -275,10 +275,10 @@ public function shouldUpdateOrganizationTeam() $api = $this->getApiMock(); $api->expects($this->once()) ->method('patch') - ->with('/teams/KnpWorld', $data) + ->with('/orgs/KnpLabs/teams/KnpWorld', $data) ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->update('KnpWorld', $data)); + $this->assertEquals($expectedValue, $api->update('KnpWorld', $data, 'KnpLabs')); } /** @@ -292,10 +292,10 @@ public function shouldUpdateWithPullPermissionWhenPermissionParamNotRecognized() $api = $this->getApiMock(); $api->expects($this->once()) ->method('patch') - ->with('/teams/KnpWorld', ['name' => 'KnpWorld', 'permission' => 'pull']) + ->with('/orgs/KnpLabs/teams/KnpWorld', ['name' => 'KnpWorld', 'permission' => 'pull']) ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->update('KnpWorld', $data)); + $this->assertEquals($expectedValue, $api->update('KnpWorld', $data, 'KnpLabs')); } /** From 7742bd1d322b4129ac56ece532ae2c45cd9d6738 Mon Sep 17 00:00:00 2001 From: Vasilis Lolos Date: Tue, 14 Apr 2020 16:30:58 +0300 Subject: [PATCH 3/8] Revert "Ignore PHPStorm's .idea directory" This reverts commit 624da985f19883e5a64f554f1fc06f2a2e5c43c2. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index d244324f4d7..ebe7b7ea7a3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ phpunit.xml composer.lock composer.phar vendor/* -.idea/* From ca63e29962c4a11d9e3573e2d8b826127e234aec Mon Sep 17 00:00:00 2001 From: Vasilis Lolos Date: Tue, 14 Apr 2020 16:38:40 +0300 Subject: [PATCH 4/8] fixes backward compatibility check --- lib/Github/Api/Organization/Teams.php | 56 ++++++++++++++++++++------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/lib/Github/Api/Organization/Teams.php b/lib/Github/Api/Organization/Teams.php index 00b57758b05..563c5907427 100644 --- a/lib/Github/Api/Organization/Teams.php +++ b/lib/Github/Api/Organization/Teams.php @@ -35,15 +35,19 @@ public function create($organization, array $params) /** * @link https://developer.github.com/v3/teams/#list-teams */ - public function show($team, $organization) + public function show($team, $organization = null) { - return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team)); + if ($organization) { + return $this->get('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team)); + } + + return $this->get('/teams/'.rawurlencode($team)); } /** * @link https://developer.github.com/v3/teams/#edit-team */ - public function update($team, array $params, $organization) + public function update($team, array $params, $organization = null) { if (!isset($params['name'])) { throw new MissingArgumentException('name'); @@ -52,47 +56,71 @@ public function update($team, array $params, $organization) $params['permission'] = 'pull'; } - return $this->patch('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team), $params); + if ($organization) { + return $this->patch('/teams/' . rawurlencode($team), $params); + } + + return $this->patch('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team), $params); } /** * @link https://developer.github.com/v3/teams/#delete-team */ - public function remove($team, $organization) + public function remove($team, $organization = null) { - return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team)); + if ($organization) { + return $this->delete('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team)); + } + + return $this->delete('/teams/' . rawurlencode($team)); } /** * @link https://developer.github.com/v3/teams/members/#list-team-members */ - public function members($team, $organization) + public function members($team, $organization = null) { - return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/members'); + if ($organization) { + return $this->get('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team) . '/members'); + } + + return $this->get('/teams/' . rawurlencode($team) . '/members'); } /** * @link https://developer.github.com/v3/teams/members/#get-team-membership */ - public function check($team, $username, $organization) + public function check($team, $username, $organization = null) { - return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); + if ($organization) { + return $this->get('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username)); + } + + return $this->get('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } /** * @link https://developer.github.com/v3/teams/members/#add-or-update-team-membership */ - public function addMember($team, $username, $organization) + public function addMember($team, $username, $organization = null) { - return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); + if ($organization) { + return $this->put('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username)); + } + + return $this->put('/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username)); } /** * @link https://developer.github.com/v3/teams/members/#remove-team-membership */ - public function removeMember($team, $username, $organization) + public function removeMember($team, $username, $organization = null) { - return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); + if ($organization) { + return $this->delete('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username)); + } + + return $this->delete('/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username)); } public function repositories($team) From 9f5071cbf7832adcd652d23fc1a69d57d0fbf51a Mon Sep 17 00:00:00 2001 From: Vasilis Lolos Date: Tue, 14 Apr 2020 16:40:48 +0300 Subject: [PATCH 5/8] fix update() --- lib/Github/Api/Organization/Teams.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Github/Api/Organization/Teams.php b/lib/Github/Api/Organization/Teams.php index 563c5907427..846cc402db2 100644 --- a/lib/Github/Api/Organization/Teams.php +++ b/lib/Github/Api/Organization/Teams.php @@ -38,7 +38,7 @@ public function create($organization, array $params) public function show($team, $organization = null) { if ($organization) { - return $this->get('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team)); + return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team)); } return $this->get('/teams/'.rawurlencode($team)); @@ -57,10 +57,10 @@ public function update($team, array $params, $organization = null) } if ($organization) { - return $this->patch('/teams/' . rawurlencode($team), $params); + return $this->patch('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team), $params); } - return $this->patch('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team), $params); + return $this->patch('/teams/'.rawurlencode($team), $params); } /** @@ -69,10 +69,10 @@ public function update($team, array $params, $organization = null) public function remove($team, $organization = null) { if ($organization) { - return $this->delete('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team)); + return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team)); } - return $this->delete('/teams/' . rawurlencode($team)); + return $this->delete('/teams/'.rawurlencode($team)); } /** @@ -81,10 +81,10 @@ public function remove($team, $organization = null) public function members($team, $organization = null) { if ($organization) { - return $this->get('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team) . '/members'); + return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team) . '/members'); } - return $this->get('/teams/' . rawurlencode($team) . '/members'); + return $this->get('/teams/'.rawurlencode($team).'/members'); } /** @@ -93,7 +93,7 @@ public function members($team, $organization = null) public function check($team, $username, $organization = null) { if ($organization) { - return $this->get('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username)); + return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team) . '/memberships/' . rawurlencode($username)); } return $this->get('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); @@ -105,10 +105,10 @@ public function check($team, $username, $organization = null) public function addMember($team, $username, $organization = null) { if ($organization) { - return $this->put('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username)); + return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team) . '/memberships/' . rawurlencode($username)); } - return $this->put('/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username)); + return $this->put('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } /** @@ -117,10 +117,10 @@ public function addMember($team, $username, $organization = null) public function removeMember($team, $username, $organization = null) { if ($organization) { - return $this->delete('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username)); + return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team) . '/memberships/' . rawurlencode($username)); } - return $this->delete('/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username)); + return $this->delete('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } public function repositories($team) From 6ecdb0a78f48e4b4b7065b8c7a6a03eec8747261 Mon Sep 17 00:00:00 2001 From: Vasilis Lolos Date: Tue, 14 Apr 2020 16:47:13 +0300 Subject: [PATCH 6/8] style fix --- lib/Github/Api/Organization/Teams.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Github/Api/Organization/Teams.php b/lib/Github/Api/Organization/Teams.php index 846cc402db2..05eb9ac7989 100644 --- a/lib/Github/Api/Organization/Teams.php +++ b/lib/Github/Api/Organization/Teams.php @@ -81,7 +81,7 @@ public function remove($team, $organization = null) public function members($team, $organization = null) { if ($organization) { - return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team) . '/members'); + return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/members'); } return $this->get('/teams/'.rawurlencode($team).'/members'); @@ -93,7 +93,7 @@ public function members($team, $organization = null) public function check($team, $username, $organization = null) { if ($organization) { - return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team) . '/memberships/' . rawurlencode($username)); + return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } return $this->get('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); @@ -105,7 +105,7 @@ public function check($team, $username, $organization = null) public function addMember($team, $username, $organization = null) { if ($organization) { - return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team) . '/memberships/' . rawurlencode($username)); + return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } return $this->put('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); @@ -117,7 +117,7 @@ public function addMember($team, $username, $organization = null) public function removeMember($team, $username, $organization = null) { if ($organization) { - return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team) . '/memberships/' . rawurlencode($username)); + return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } return $this->delete('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); From 6ceeb55dddafb90367db36b9a875c3b86ce36c4c Mon Sep 17 00:00:00 2001 From: Vasilis Lolos Date: Mon, 20 Apr 2020 17:54:58 +0300 Subject: [PATCH 7/8] changes based on @acrobat's suggestions --- lib/Github/Api/Organization/Teams.php | 57 ++++++++++++++++----------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/lib/Github/Api/Organization/Teams.php b/lib/Github/Api/Organization/Teams.php index 05eb9ac7989..00361734acc 100644 --- a/lib/Github/Api/Organization/Teams.php +++ b/lib/Github/Api/Organization/Teams.php @@ -7,7 +7,6 @@ /** * @link http://developer.github.com/v3/orgs/teams/ - * * @author Joseph Bielawski */ class Teams extends AbstractApi @@ -37,11 +36,13 @@ public function create($organization, array $params) */ public function show($team, $organization = null) { - if ($organization) { - return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team)); + if (null === $organization) { + @trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED); + + return $this->get('/teams/'.rawurlencode($team)); } - return $this->get('/teams/'.rawurlencode($team)); + return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team)); } /** @@ -56,11 +57,13 @@ public function update($team, array $params, $organization = null) $params['permission'] = 'pull'; } - if ($organization) { - return $this->patch('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team), $params); + if (null === $organization) { + @trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED); + + return $this->patch('/teams/'.rawurlencode($team), $params); } - return $this->patch('/teams/'.rawurlencode($team), $params); + return $this->patch('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team), $params); } /** @@ -68,11 +71,13 @@ public function update($team, array $params, $organization = null) */ public function remove($team, $organization = null) { - if ($organization) { - return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team)); + if (null === $organization) { + @trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED); + + return $this->delete('/teams/'.rawurlencode($team)); } - return $this->delete('/teams/'.rawurlencode($team)); + return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team)); } /** @@ -80,11 +85,13 @@ public function remove($team, $organization = null) */ public function members($team, $organization = null) { - if ($organization) { - return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/members'); + if (null === $organization) { + @trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED); + + return $this->get('/teams/'.rawurlencode($team).'/members'); } - return $this->get('/teams/'.rawurlencode($team).'/members'); + return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/members'); } /** @@ -92,11 +99,13 @@ public function members($team, $organization = null) */ public function check($team, $username, $organization = null) { - if ($organization) { - return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); + if (null === $organization) { + @trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED); + + return $this->get('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } - return $this->get('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); + return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } /** @@ -104,11 +113,13 @@ public function check($team, $username, $organization = null) */ public function addMember($team, $username, $organization = null) { - if ($organization) { - return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); + if (null === $organization) { + @trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED); + + return $this->put('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } - return $this->put('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); + return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } /** @@ -116,11 +127,13 @@ public function addMember($team, $username, $organization = null) */ public function removeMember($team, $username, $organization = null) { - if ($organization) { - return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); + if (null === $organization) { + @trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED); + + return $this->delete('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } - return $this->delete('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); + return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); } public function repositories($team) From 25504440b6b2fa6b6800c7c08741e55e13848a41 Mon Sep 17 00:00:00 2001 From: Vasilis Lolos Date: Mon, 20 Apr 2020 17:56:41 +0300 Subject: [PATCH 8/8] styling fix --- lib/Github/Api/Organization/Teams.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Github/Api/Organization/Teams.php b/lib/Github/Api/Organization/Teams.php index 00361734acc..8b84028db24 100644 --- a/lib/Github/Api/Organization/Teams.php +++ b/lib/Github/Api/Organization/Teams.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/orgs/teams/ + * * @author Joseph Bielawski */ class Teams extends AbstractApi