Skip to content

Commit a5ecd54

Browse files
authored
added phpdocs for better type hinting (#376)
1 parent 0421764 commit a5ecd54

File tree

30 files changed

+124
-11
lines changed

30 files changed

+124
-11
lines changed

src/BlockStorage/v2/Models/Snapshot.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ public function retrieve()
8484
}
8585

8686
/**
87+
* {@inheritdoc}
88+
*
8789
* @param array $userOptions {@see \OpenStack\BlockStorage\v2\Api::postSnapshots}
8890
*/
8991
public function create(array $userOptions): Creatable

src/BlockStorage/v2/Models/Volume.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ public function retrieve()
110110
}
111111

112112
/**
113+
* {@inheritdoc}
114+
*
113115
* @param array $userOptions {@see \OpenStack\BlockStorage\v2\Api::postVolumes}
114116
*/
115117
public function create(array $userOptions): Creatable

src/BlockStorage/v2/Models/VolumeType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class VolumeType extends OperatorResource implements Listable, Creatable, Update
2525
protected $resourcesKey = 'volume_types';
2626

2727
/**
28+
* {@inheritdoc}
29+
*
2830
* @param array $userOptions {@see \OpenStack\BlockStorage\v2\Api::postTypes}
2931
*/
3032
public function create(array $userOptions): Creatable

src/BlockStorage/v2/Service.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function createVolume(array $userOptions): Volume
3131
*
3232
* @param bool $detail if set to TRUE, more information will be returned
3333
* @param array $userOptions {@see Api::getVolumes}
34+
* @return \Generator<mixed, \OpenStack\BlockStorage\v2\Models\Volume>
3435
*/
3536
public function listVolumes(bool $detail = false, array $userOptions = []): \Generator
3637
{
@@ -58,6 +59,9 @@ public function createVolumeType(array $userOptions): VolumeType
5859
return $this->model(VolumeType::class)->create($userOptions);
5960
}
6061

62+
/**
63+
* @return \Generator<mixed, \OpenStack\BlockStorage\v2\Models\VolumeType>
64+
*/
6165
public function listVolumeTypes(): \Generator
6266
{
6367
return $this->model(VolumeType::class)->enumerate($this->api->getTypes(), []);
@@ -79,6 +83,9 @@ public function createSnapshot(array $userOptions): Snapshot
7983
return $this->model(Snapshot::class)->create($userOptions);
8084
}
8185

86+
/**
87+
* @return \Generator<mixed, \OpenStack\BlockStorage\v2\Models\Snapshot>
88+
*/
8289
public function listSnapshots(bool $detail = false, array $userOptions = []): \Generator
8390
{
8491
$def = (true === $detail) ? $this->api->getSnapshotsDetail() : $this->api->getSnapshots();

src/Common/Resource/AbstractResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function populateFromResponse(ResponseInterface $response)
5555
/**
5656
* Populates the current resource from a data array.
5757
*
58-
* @return mixed|void
58+
* @return self
5959
*/
6060
public function populateFromArray(array $array)
6161
{

src/Common/Resource/Creatable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface Creatable
1212
/**
1313
* Create a new resource according to the configuration set in the options.
1414
*
15-
* @return self
15+
* @return static
1616
*/
1717
public function create(array $userOptions): Creatable;
1818
}

src/Common/Resource/Listable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface Listable
2222
* @param array $userVals The user values
2323
* @param callable $mapFn an optional callback that will be executed on every resource iteration
2424
*
25-
* @returns void
25+
* @returns \Generator<mixed, static>
2626
*/
2727
public function enumerate(array $def, array $userVals = [], callable $mapFn = null);
2828
}

src/Common/Resource/OperatorResource.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ private function getResourcesKey(): string
6868
}
6969

7070
/**
71-
* {@inheritdoc}
71+
* Creates a generator for enumerating over a collection of resources returned by the request.
72+
*
73+
* @returns \Generator<mixed, static>
7274
*/
7375
public function enumerate(array $def, array $userVals = [], callable $mapFn = null): \Generator
7476
{
@@ -101,6 +103,11 @@ public function enumerate(array $def, array $userVals = [], callable $mapFn = nu
101103
return $iterator();
102104
}
103105

106+
/**
107+
* Extracts multiple instances of the current resource from a response.
108+
*
109+
* @return array<self>
110+
*/
104111
public function extractMultipleInstances(ResponseInterface $response, string $key = null): array
105112
{
106113
$key = $key ?: $this->getResourcesKey();

src/Common/Resource/ResourceInterface.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@ interface ResourceInterface
1515
* All models which represent an API resource should be able to be populated
1616
* from a {@see ResponseInterface} object.
1717
*
18+
* @param \Psr\Http\Message\ResponseInterface $response
1819
* @return self
1920
*/
2021
public function populateFromResponse(ResponseInterface $response);
2122

2223
/**
23-
* @return mixed
24+
* @return self
2425
*/
2526
public function populateFromArray(array $data);
2627

2728
/**
28-
* @param string $name the name of the model class
29+
* @template T of \OpenStack\Common\Resource\ResourceInterface
30+
* @param class-string<T> $class the name of the model class
2931
* @param mixed $data either a {@see ResponseInterface} or data array that will populate the newly
3032
* created model class
3133
*
32-
* @return \OpenStack\Common\Resource\ResourceInterface
34+
* @return T
3335
*/
3436
public function model(string $class, $data = null): ResourceInterface;
3537
}

src/Compute/v2/Models/Keypair.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public function retrieve()
7575
$this->populateFromResponse($response);
7676
}
7777

78+
/**
79+
* {@inheritdoc}
80+
*/
7881
public function create(array $userOptions): Creatable
7982
{
8083
$response = $this->execute($this->api->postKeypair(), $userOptions);

0 commit comments

Comments
 (0)