Skip to content

Commit ce2a89b

Browse files
authored
Merge pull request #93 from packagist/fix/rename-deprecated-param
Rename all instances of deprecated param defaultSubrepositoryAccess to defaultSuborganizationAccess
2 parents c0eaedc + c1cdb87 commit ce2a89b

6 files changed

Lines changed: 48 additions & 48 deletions

File tree

src/Api/Packages.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,23 @@ public function show($packageIdOrName)
6060
return $this->get(sprintf('/packages/%s/', $packageIdOrName));
6161
}
6262

63-
public function createVcsPackage($url, $credentialId = null, $type = 'vcs', $defaultSubrepositoryAccess = null)
63+
public function createVcsPackage($url, $credentialId = null, $type = 'vcs', $defaultSuborganizationAccess = null)
6464
{
65-
$data = new VcsPackageConfig($url, $credentialId, $type, $defaultSubrepositoryAccess);
65+
$data = new VcsPackageConfig($url, $credentialId, $type, $defaultSuborganizationAccess);
6666

6767
return $this->post('/packages/', $data->toParameters());
6868
}
6969

70-
public function createCustomPackage($customJson, $credentialId = null, $defaultSubrepositoryAccess = null)
70+
public function createCustomPackage($customJson, $credentialId = null, $defaultSuborganizationAccess = null)
7171
{
72-
$data = new CustomPackageConfig($customJson, $credentialId, $defaultSubrepositoryAccess);
72+
$data = new CustomPackageConfig($customJson, $credentialId, $defaultSuborganizationAccess);
7373

7474
return $this->post('/packages/', $data->toParameters());
7575
}
7676

77-
public function createArtifactPackage(array $artifactPackageFileIds, $defaultSubrepositoryAccess = null)
77+
public function createArtifactPackage(array $artifactPackageFileIds, $defaultSuborganizationAccess = null)
7878
{
79-
$data = new ArtifactPackageConfig($artifactPackageFileIds, $defaultSubrepositoryAccess);
79+
$data = new ArtifactPackageConfig($artifactPackageFileIds, $defaultSuborganizationAccess);
8080

8181
return $this->post('/packages/', $data->toParameters());
8282
}
@@ -90,16 +90,16 @@ public function updateVcsPackage($packageName, $url, $credentialId = null)
9090
return $this->editVcsPackage($packageName, $url, $credentialId);
9191
}
9292

93-
public function editVcsPackage($packageIdOrName, $url, $credentialId = null, $type = 'vcs', $defaultSubrepositoryAccess = null)
93+
public function editVcsPackage($packageIdOrName, $url, $credentialId = null, $type = 'vcs', $defaultSuborganizationAccess = null)
9494
{
95-
$data = new VcsPackageConfig($url, $credentialId, $type, $defaultSubrepositoryAccess);
95+
$data = new VcsPackageConfig($url, $credentialId, $type, $defaultSuborganizationAccess);
9696

9797
return $this->put(sprintf('/packages/%s/', $packageIdOrName), $data->toParameters());
9898
}
9999

100-
public function editArtifactPackage($packageIdOrName, array $artifactPackageFileIds, $defaultSubrepositoryAccess = null)
100+
public function editArtifactPackage($packageIdOrName, array $artifactPackageFileIds, $defaultSuborganizationAccess = null)
101101
{
102-
$data = new ArtifactPackageConfig($artifactPackageFileIds, $defaultSubrepositoryAccess);
102+
$data = new ArtifactPackageConfig($artifactPackageFileIds, $defaultSuborganizationAccess);
103103

104104
return $this->put(sprintf('/packages/%s/', $packageIdOrName), $data->toParameters());
105105
}
@@ -113,9 +113,9 @@ public function updateCustomPackage($packageName, $customJson, $credentialId = n
113113
return $this->editCustomPackage($packageName, $customJson, $credentialId);
114114
}
115115

116-
public function editCustomPackage($packageIdOrName, $customJson, $credentialId = null, $defaultSubrepositoryAccess = null)
116+
public function editCustomPackage($packageIdOrName, $customJson, $credentialId = null, $defaultSuborganizationAccess = null)
117117
{
118-
$data = new CustomPackageConfig($customJson, $credentialId, $defaultSubrepositoryAccess);
118+
$data = new CustomPackageConfig($customJson, $credentialId, $defaultSuborganizationAccess);
119119

120120
return $this->put(sprintf('/packages/%s/', $packageIdOrName), $data->toParameters());
121121
}

src/Api/Subrepositories/Packages.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,30 @@ public function show($subrepositoryName, $packageIdOrName)
3333
return $this->get(sprintf('/subrepositories/%s/packages/%s/', $subrepositoryName, $packageIdOrName));
3434
}
3535

36-
public function createVcsPackage($subrepositoryName, $url, $credentialId = null, $type = 'vcs', $defaultSubrepositoryAccess = null)
36+
public function createVcsPackage($subrepositoryName, $url, $credentialId = null, $type = 'vcs', $defaultSuborganizationAccess = null)
3737
{
38-
$data = new VcsPackageConfig($url, $credentialId, $type, $defaultSubrepositoryAccess);
38+
$data = new VcsPackageConfig($url, $credentialId, $type, $defaultSuborganizationAccess);
3939

4040
return $this->post(sprintf('/subrepositories/%s/packages/', $subrepositoryName), $data->toParameters());
4141
}
4242

43-
public function createCustomPackage($subrepositoryName, $customJson, $credentialId = null, $defaultSubrepositoryAccess = null)
43+
public function createCustomPackage($subrepositoryName, $customJson, $credentialId = null, $defaultSuborganizationAccess = null)
4444
{
45-
$data = new CustomPackageConfig($customJson, $credentialId, $defaultSubrepositoryAccess);
45+
$data = new CustomPackageConfig($customJson, $credentialId, $defaultSuborganizationAccess);
4646

4747
return $this->post(sprintf('/subrepositories/%s/packages/', $subrepositoryName), $data->toParameters());
4848
}
4949

50-
public function editVcsPackage($subrepositoryName, $packageIdOrName, $url, $credentialId = null, $type = 'vcs', $defaultSubrepositoryAccess = null)
50+
public function editVcsPackage($subrepositoryName, $packageIdOrName, $url, $credentialId = null, $type = 'vcs', $defaultSuborganizationAccess = null)
5151
{
52-
$data = new VcsPackageConfig($url, $credentialId, $type, $defaultSubrepositoryAccess);
52+
$data = new VcsPackageConfig($url, $credentialId, $type, $defaultSuborganizationAccess);
5353

5454
return $this->put(sprintf('/subrepositories/%s/packages/%s/', $subrepositoryName, $packageIdOrName), $data->toParameters());
5555
}
5656

57-
public function editCustomPackage($subrepositoryName, $packageIdOrName, $customJson, $credentialId = null, $defaultSubrepositoryAccess = null)
57+
public function editCustomPackage($subrepositoryName, $packageIdOrName, $customJson, $credentialId = null, $defaultSuborganizationAccess = null)
5858
{
59-
$data = new CustomPackageConfig($customJson, $credentialId, $defaultSubrepositoryAccess);
59+
$data = new CustomPackageConfig($customJson, $credentialId, $defaultSuborganizationAccess);
6060

6161
return $this->put(sprintf('/subrepositories/%s/packages/%s/', $subrepositoryName, $packageIdOrName), $data->toParameters());
6262
}

src/Payload/ArtifactPackageConfig.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ class ArtifactPackageConfig
1818
/** @var int[] */
1919
private $artifactPackageFileIds;
2020
/** @var ?string */
21-
private $defaultSubrepositoryAccess;
21+
private $defaultSuborganizationAccess;
2222

2323
/**
2424
* @param int[] $artifactPackageFileIds
25-
* @param ?string $defaultSubrepositoryAccess
25+
* @param ?string $defaultSuborganizationAccess
2626
*/
27-
public function __construct(array $artifactPackageFileIds, $defaultSubrepositoryAccess)
27+
public function __construct(array $artifactPackageFileIds, $defaultSuborganizationAccess)
2828
{
2929
$this->artifactPackageFileIds = $artifactPackageFileIds;
30-
$this->defaultSubrepositoryAccess = $defaultSubrepositoryAccess;
30+
$this->defaultSuborganizationAccess = $defaultSuborganizationAccess;
3131
}
3232

3333
/**
34-
* @return array{repoType: string, artifactIds: int[], defaultSubrepositoryAccess?: string}
34+
* @return array{repoType: string, artifactIds: int[], defaultSuborganizationAccess?: string}
3535
*/
3636
public function toParameters(): array
3737
{
@@ -40,8 +40,8 @@ public function toParameters(): array
4040
'artifactIds' => $this->artifactPackageFileIds,
4141
];
4242

43-
if ($this->defaultSubrepositoryAccess) {
44-
$data['defaultSubrepositoryAccess'] = $this->defaultSubrepositoryAccess;
43+
if ($this->defaultSuborganizationAccess) {
44+
$data['defaultSuborganizationAccess'] = $this->defaultSuborganizationAccess;
4545
}
4646

4747
return $data;

src/Payload/CustomPackageConfig.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@ class CustomPackageConfig
2020
/** @var ?int */
2121
private $credentialId;
2222
/** @var ?string */
23-
private $defaultSubrepositoryAccess;
23+
private $defaultSuborganizationAccess;
2424

2525
/**
2626
* @param string|array|object $customJson
2727
* @param ?int $credentialId
28-
* @param ?string $defaultSubrepositoryAccess
28+
* @param ?string $defaultSuborganizationAccess
2929
*/
30-
public function __construct($customJson, $credentialId, $defaultSubrepositoryAccess)
30+
public function __construct($customJson, $credentialId, $defaultSuborganizationAccess)
3131
{
3232
if (is_array($customJson) || is_object($customJson)) {
3333
$customJson = json_encode($customJson);
3434
}
3535

3636
$this->customJson = $customJson;
3737
$this->credentialId = $credentialId;
38-
$this->defaultSubrepositoryAccess = $defaultSubrepositoryAccess;
38+
$this->defaultSuborganizationAccess = $defaultSuborganizationAccess;
3939
}
4040

4141
/**
42-
* @return array{repoType: string, repoConfig: string, credentials: ?int, defaultSubrepositoryAccess?: string}
42+
* @return array{repoType: string, repoConfig: string, credentials: ?int, defaultSuborganizationAccess?: string}
4343
*/
4444
public function toParameters(): array
4545
{
@@ -49,8 +49,8 @@ public function toParameters(): array
4949
'credentials' => $this->credentialId,
5050
];
5151

52-
if ($this->defaultSubrepositoryAccess) {
53-
$data['defaultSubrepositoryAccess'] = $this->defaultSubrepositoryAccess;
52+
if ($this->defaultSuborganizationAccess) {
53+
$data['defaultSuborganizationAccess'] = $this->defaultSuborganizationAccess;
5454
}
5555

5656
return $data;

src/Payload/VcsPackageConfig.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ class VcsPackageConfig
2222
/** @var string */
2323
private $type;
2424
/** @var ?string */
25-
private $defaultSubrepositoryAccess;
25+
private $defaultSuborganizationAccess;
2626

2727
/**
2828
* @param string $url
2929
* @param ?int $credentialId
3030
* @param string $type
31-
* @param ?string $defaultSubrepositoryAccess
31+
* @param ?string $defaultSuborganizationAccess
3232
*/
33-
public function __construct($url, $credentialId, $type, $defaultSubrepositoryAccess)
33+
public function __construct($url, $credentialId, $type, $defaultSuborganizationAccess)
3434
{
3535
$this->url = $url;
3636
$this->credentialId = $credentialId;
3737
$this->type = $type;
38-
$this->defaultSubrepositoryAccess = $defaultSubrepositoryAccess;
38+
$this->defaultSuborganizationAccess = $defaultSuborganizationAccess;
3939
}
4040

4141
/**
42-
* @return array{repoType: string, repoUrl: string, credentials: ?int, defaultSubrepositoryAccess?: string}
42+
* @return array{repoType: string, repoUrl: string, credentials: ?int, defaultSuborganizationAccess?: string}
4343
*/
4444
public function toParameters(): array
4545
{
@@ -49,8 +49,8 @@ public function toParameters(): array
4949
'credentials' => $this->credentialId,
5050
];
5151

52-
if ($this->defaultSubrepositoryAccess) {
53-
$data['defaultSubrepositoryAccess'] = $this->defaultSubrepositoryAccess;
52+
if ($this->defaultSuborganizationAccess) {
53+
$data['defaultSuborganizationAccess'] = $this->defaultSuborganizationAccess;
5454
}
5555

5656
return $data;

tests/Api/PackagesTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testCreateVcsPackage()
106106
$this->assertSame($expected, $api->createVcsPackage('localhost'));
107107
}
108108

109-
public function testCreateVcsPackageWithDefaultSubrepositoryAccess()
109+
public function testCreateVcsPackageWithDefaultSuborganizationAccess()
110110
{
111111
$expected = [
112112
'id' => 'job-id',
@@ -117,7 +117,7 @@ public function testCreateVcsPackageWithDefaultSubrepositoryAccess()
117117
$api = $this->getApiMock();
118118
$api->expects($this->once())
119119
->method('post')
120-
->with($this->equalTo('/packages/'), $this->equalTo(['repoType' => 'vcs', 'repoUrl' => 'localhost', 'credentials' => null, 'defaultSubrepositoryAccess' => 'no-access']))
120+
->with($this->equalTo('/packages/'), $this->equalTo(['repoType' => 'vcs', 'repoUrl' => 'localhost', 'credentials' => null, 'defaultSuborganizationAccess' => 'no-access']))
121121
->willReturn($expected);
122122

123123
$this->assertSame($expected, $api->createVcsPackage('localhost', null, 'vcs', 'no-access'));
@@ -126,7 +126,7 @@ public function testCreateVcsPackageWithDefaultSubrepositoryAccess()
126126
/**
127127
* @dataProvider customProvider
128128
*/
129-
public function testCreateCustomPackage($customJson, $defaultSubrepositoryAccess, array $expectedPayload)
129+
public function testCreateCustomPackage($customJson, $defaultSuborganizationAccess, array $expectedPayload)
130130
{
131131
$expected = [
132132
'id' => 'job-id',
@@ -140,7 +140,7 @@ public function testCreateCustomPackage($customJson, $defaultSubrepositoryAccess
140140
->with($this->equalTo('/packages/'), $this->equalTo($expectedPayload))
141141
->willReturn($expected);
142142

143-
$this->assertSame($expected, $api->createCustomPackage($customJson, null, $defaultSubrepositoryAccess));
143+
$this->assertSame($expected, $api->createCustomPackage($customJson, null, $defaultSuborganizationAccess));
144144
}
145145

146146
public function customProvider()
@@ -149,11 +149,11 @@ public function customProvider()
149149
['{}', null, ['repoType' => 'package', 'repoConfig' => '{}', 'credentials' => null]],
150150
[new \stdClass(), null, ['repoType' => 'package', 'repoConfig' => '{}', 'credentials' => null]],
151151
[[], null, ['repoType' => 'package', 'repoConfig' => '[]', 'credentials' => null]],
152-
['{}', 'no-access', ['repoType' => 'package', 'repoConfig' => '{}', 'credentials' => null, 'defaultSubrepositoryAccess' => 'no-access']],
152+
['{}', 'no-access', ['repoType' => 'package', 'repoConfig' => '{}', 'credentials' => null, 'defaultSuborganizationAccess' => 'no-access']],
153153
];
154154
}
155155

156-
public function testCreateArtifactPackageWithDefaultSubrepositoryAccess()
156+
public function testCreateArtifactPackageWithDefaultSuborganizationAccess()
157157
{
158158
$expected = [
159159
'id' => 'job-id',
@@ -164,7 +164,7 @@ public function testCreateArtifactPackageWithDefaultSubrepositoryAccess()
164164
$api = $this->getApiMock();
165165
$api->expects($this->once())
166166
->method('post')
167-
->with($this->equalTo('/packages/'), $this->equalTo(['repoType' => 'artifact', 'artifactIds' => [42], 'defaultSubrepositoryAccess' => 'no-access']))
167+
->with($this->equalTo('/packages/'), $this->equalTo(['repoType' => 'artifact', 'artifactIds' => [42], 'defaultSuborganizationAccess' => 'no-access']))
168168
->willReturn($expected);
169169

170170
$this->assertSame($expected, $api->createArtifactPackage([42], 'no-access'));

0 commit comments

Comments
 (0)