1 | <?php declare(strict_types=1); |
||
14 | class Service extends AbstractService |
||
15 | { |
||
16 | /** |
||
17 | * Provisions a new bootable volume, based either on an existing volume, image or snapshot. |
||
18 | * You must have enough volume storage quota remaining to create a volume of size requested. |
||
19 | * |
||
20 | * @param array $userOptions {@see Api::postVolumes} |
||
21 | * |
||
22 | 1 | * @return Volume |
|
23 | */ |
||
24 | 1 | public function createVolume(array $userOptions): Volume |
|
28 | |||
29 | /** |
||
30 | * Lists all available volumes. |
||
31 | * |
||
32 | * @param bool $detail If set to TRUE, more information will be returned. |
||
33 | * @param array $userOptions {@see Api::getVolumes} |
||
34 | * |
||
35 | 1 | * @return \Generator |
|
36 | */ |
||
37 | 1 | public function listVolumes(bool $detail = false, array $userOptions = []): \Generator |
|
42 | |||
43 | /** |
||
44 | * @param string $volumeId The UUID of the volume being retrieved. |
||
45 | * |
||
46 | 1 | * @return Volume |
|
47 | */ |
||
48 | 1 | public function getVolume(string $volumeId): Volume |
|
54 | |||
55 | /** |
||
56 | * @param array $userOptions {@see Api::postTypes} |
||
57 | * |
||
58 | 1 | * @return VolumeType |
|
59 | */ |
||
60 | 1 | public function createVolumeType(array $userOptions): VolumeType |
|
64 | |||
65 | /** |
||
66 | 1 | * @return \Generator |
|
67 | */ |
||
68 | 1 | public function listVolumeTypes(): \Generator |
|
72 | |||
73 | /** |
||
74 | * @param string $typeId |
||
75 | * |
||
76 | 1 | * @return VolumeType |
|
77 | */ |
||
78 | 1 | public function getVolumeType(string $typeId): VolumeType |
|
84 | |||
85 | /** |
||
86 | * @param array $userOptions {@see Api::postSnapshots} |
||
87 | * |
||
88 | 1 | * @return Snapshot |
|
89 | */ |
||
90 | 1 | public function createSnapshot(array $userOptions): Snapshot |
|
94 | |||
95 | /** |
||
96 | 1 | * @return \Generator |
|
97 | */ |
||
98 | 1 | public function listSnapshots(bool $detail = false, array $userOptions = []): \Generator |
|
103 | |||
104 | /** |
||
105 | * @param string $snapshotId |
||
106 | * |
||
107 | 1 | * @return Snapshot |
|
108 | */ |
||
109 | 1 | public function getSnapshot(string $snapshotId): Snapshot |
|
115 | |||
116 | /** |
||
117 | * Shows A Quota for a tenant |
||
118 | * |
||
119 | * @param string $tenantId |
||
120 | * |
||
121 | * @return QuotaSet |
||
122 | */ |
||
123 | public function getQuotaSet(string $tenantId): QuotaSet |
||
130 | } |
||
131 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: