Skip to content

Commit 00352cc

Browse files
author
Jamie Hannaford
committed
Shift to PHP 7 return types
1 parent 4ba218f commit 00352cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+620
-585
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626
],
2727
"require": {
28-
"php-opencloud/common": "dev-master"
28+
"php-opencloud/common": "~1.0"
2929
},
3030
"require-dev": {
3131
"phpunit/phpunit": "~4.0",
@@ -35,4 +35,4 @@
3535
"jakub-onderka/php-parallel-lint": "0.*",
3636
"fabpot/php-cs-fixer": "~1.0"
3737
}
38-
}
38+
}

src/BlockStorage/v2/Api.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php declare (strict_types=1);
2+
23
namespace OpenStack\BlockStorage\v2;
34

45
use OpenCloud\Common\Api\AbstractApi;
@@ -10,7 +11,7 @@ public function __construct()
1011
$this->params = new Params;
1112
}
1213

13-
public function postVolumes()
14+
public function postVolumes(): array
1415
{
1516
return [
1617
'method' => 'POST',
@@ -30,7 +31,7 @@ public function postVolumes()
3031
];
3132
}
3233

33-
public function getVolumes()
34+
public function getVolumes(): array
3435
{
3536
return [
3637
'method' => 'GET',
@@ -43,7 +44,7 @@ public function getVolumes()
4344
];
4445
}
4546

46-
public function getVolumesDetail()
47+
public function getVolumesDetail(): array
4748
{
4849
return [
4950
'method' => 'GET',
@@ -56,7 +57,7 @@ public function getVolumesDetail()
5657
];
5758
}
5859

59-
public function getVolume()
60+
public function getVolume(): array
6061
{
6162
return [
6263
'method' => 'GET',
@@ -65,7 +66,7 @@ public function getVolume()
6566
];
6667
}
6768

68-
public function putVolume()
69+
public function putVolume(): array
6970
{
7071
return [
7172
'method' => 'PUT',
@@ -79,7 +80,7 @@ public function putVolume()
7980
];
8081
}
8182

82-
public function deleteVolume()
83+
public function deleteVolume(): array
8384
{
8485
return [
8586
'method' => 'DELETE',
@@ -88,7 +89,7 @@ public function deleteVolume()
8889
];
8990
}
9091

91-
public function getVolumeMetadata()
92+
public function getVolumeMetadata(): array
9293
{
9394
return [
9495
'method' => 'GET',
@@ -97,7 +98,7 @@ public function getVolumeMetadata()
9798
];
9899
}
99100

100-
public function putVolumeMetadata()
101+
public function putVolumeMetadata(): array
101102
{
102103
return [
103104
'method' => 'PUT',
@@ -109,7 +110,7 @@ public function putVolumeMetadata()
109110
];
110111
}
111112

112-
public function getTypes()
113+
public function getTypes(): array
113114
{
114115
return [
115116
'method' => 'GET',
@@ -118,7 +119,7 @@ public function getTypes()
118119
];
119120
}
120121

121-
public function postTypes()
122+
public function postTypes(): array
122123
{
123124
return [
124125
'method' => 'POST',
@@ -131,7 +132,7 @@ public function postTypes()
131132
];
132133
}
133134

134-
public function putType()
135+
public function putType(): array
135136
{
136137
return [
137138
'method' => 'PUT',
@@ -145,7 +146,7 @@ public function putType()
145146
];
146147
}
147148

148-
public function getType()
149+
public function getType(): array
149150
{
150151
return [
151152
'method' => 'GET',
@@ -154,7 +155,7 @@ public function getType()
154155
];
155156
}
156157

157-
public function deleteType()
158+
public function deleteType(): array
158159
{
159160
return [
160161
'method' => 'DELETE',
@@ -163,7 +164,7 @@ public function deleteType()
163164
];
164165
}
165166

166-
public function postSnapshots()
167+
public function postSnapshots(): array
167168
{
168169
return [
169170
'method' => 'POST',
@@ -178,7 +179,7 @@ public function postSnapshots()
178179
];
179180
}
180181

181-
public function getSnapshots()
182+
public function getSnapshots(): array
182183
{
183184
return [
184185
'method' => 'GET',
@@ -192,7 +193,7 @@ public function getSnapshots()
192193
];
193194
}
194195

195-
public function getSnapshotsDetail()
196+
public function getSnapshotsDetail(): array
196197
{
197198
return [
198199
'method' => 'GET',
@@ -201,7 +202,7 @@ public function getSnapshotsDetail()
201202
];
202203
}
203204

204-
public function getSnapshot()
205+
public function getSnapshot(): array
205206
{
206207
return [
207208
'method' => 'GET',
@@ -210,7 +211,7 @@ public function getSnapshot()
210211
];
211212
}
212213

213-
public function putSnapshot()
214+
public function putSnapshot(): array
214215
{
215216
return [
216217
'method' => 'PUT',
@@ -224,7 +225,7 @@ public function putSnapshot()
224225
];
225226
}
226227

227-
public function deleteSnapshot()
228+
public function deleteSnapshot(): array
228229
{
229230
return [
230231
'method' => 'DELETE',
@@ -233,7 +234,7 @@ public function deleteSnapshot()
233234
];
234235
}
235236

236-
public function getSnapshotMetadata()
237+
public function getSnapshotMetadata(): array
237238
{
238239
return [
239240
'method' => 'GET',
@@ -242,7 +243,7 @@ public function getSnapshotMetadata()
242243
];
243244
}
244245

245-
public function putSnapshotMetadata()
246+
public function putSnapshotMetadata(): array
246247
{
247248
return [
248249
'method' => 'PUT',

src/BlockStorage/v2/Models/Snapshot.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Snapshot extends AbstractResource implements Listable, Creatable, Updateab
5353
'volume_id' => 'volumeId',
5454
];
5555

56-
public function populateFromResponse(ResponseInterface $response)
56+
public function populateFromResponse(ResponseInterface $response): self
5757
{
5858
parent::populateFromResponse($response);
5959
$this->metadata = $this->parseMetadata($response);
@@ -63,15 +63,15 @@ public function populateFromResponse(ResponseInterface $response)
6363
public function retrieve()
6464
{
6565
$response = $this->executeWithState($this->api->getSnapshot());
66-
return $this->populateFromResponse($response);
66+
$this->populateFromResponse($response);
6767
}
6868

6969
/**
7070
* @param array $userOptions {@see \OpenStack\BlockStorage\v2\Api::postSnapshots}
7171
*
72-
* @return self
72+
* @return Creatable
7373
*/
74-
public function create(array $userOptions)
74+
public function create(array $userOptions): Creatable
7575
{
7676
$response = $this->execute($this->api->postSnapshots(), $userOptions);
7777
return $this->populateFromResponse($response);
@@ -87,7 +87,7 @@ public function delete()
8787
$this->executeWithState($this->api->deleteSnapshot());
8888
}
8989

90-
public function getMetadata()
90+
public function getMetadata(): array
9191
{
9292
$response = $this->executeWithState($this->api->getSnapshotMetadata());
9393
$this->metadata = $this->parseMetadata($response);
@@ -107,7 +107,7 @@ public function resetMetadata(array $metadata)
107107
$this->executeWithState($this->api->putSnapshotMetadata());
108108
}
109109

110-
public function parseMetadata(ResponseInterface $response)
110+
public function parseMetadata(ResponseInterface $response): array
111111
{
112112
$json = Utils::jsonDecode($response);
113113
return isset($json['metadata']) ? $json['metadata'] : [];

src/BlockStorage/v2/Models/Volume.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Volume extends AbstractResource implements Creatable, Listable, Updateable
6767
'volume_type' => 'volumeTypeName',
6868
];
6969

70-
public function populateFromResponse(ResponseInterface $response)
70+
public function populateFromResponse(ResponseInterface $response): self
7171
{
7272
parent::populateFromResponse($response);
7373
$this->metadata = $this->parseMetadata($response);
@@ -77,35 +77,32 @@ public function populateFromResponse(ResponseInterface $response)
7777
public function retrieve()
7878
{
7979
$response = $this->executeWithState($this->api->getVolume());
80-
return $this->populateFromResponse($response);
80+
$this->populateFromResponse($response);
8181
}
8282

8383
/**
8484
* @param array $userOptions {@see \OpenStack\BlockStorage\v2\Api::postVolumes}
8585
*
86-
* @return self
86+
* @return Creatable
8787
*/
88-
public function create(array $userOptions)
88+
public function create(array $userOptions): Creatable
8989
{
9090
$response = $this->execute($this->api->postVolumes(), $userOptions);
9191
return $this->populateFromResponse($response);
9292
}
9393

94-
/**
95-
* @return self
96-
*/
9794
public function update()
9895
{
9996
$response = $this->executeWithState($this->api->putVolume());
100-
return $this->populateFromResponse($response);
97+
$this->populateFromResponse($response);
10198
}
10299

103100
public function delete()
104101
{
105102
$this->executeWithState($this->api->deleteVolume());
106103
}
107104

108-
public function getMetadata()
105+
public function getMetadata(): array
109106
{
110107
$response = $this->executeWithState($this->api->getVolumeMetadata());
111108
$this->metadata = $this->parseMetadata($response);
@@ -125,7 +122,7 @@ public function resetMetadata(array $metadata)
125122
$this->executeWithState($this->api->putVolumeMetadata());
126123
}
127124

128-
public function parseMetadata(ResponseInterface $response)
125+
public function parseMetadata(ResponseInterface $response): array
129126
{
130127
$json = Utils::jsonDecode($response);
131128
return isset($json['metadata']) ? $json['metadata'] : [];

src/BlockStorage/v2/Models/VolumeType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class VolumeType extends AbstractResource implements Listable, Creatable, Update
2525
/**
2626
* @param array $userOptions {@see \OpenStack\BlockStorage\v2\Api::postTypes}
2727
*
28-
* @return self
28+
* @return Creatable
2929
*/
30-
public function create(array $userOptions)
30+
public function create(array $userOptions): Creatable
3131
{
3232
$response = $this->execute($this->api->postTypes(), $userOptions);
3333
return $this->populateFromResponse($response);

0 commit comments

Comments
 (0)