1 | <?php declare(strict_types=1); |
||
23 | class Service extends AbstractService |
||
24 | { |
||
25 | 1 | /** |
|
26 | * Create a new server resource. This operation will provision a new virtual machine on a host chosen by your |
||
27 | 1 | * service API. |
|
28 | * |
||
29 | * @param array $options {@see \OpenStack\Compute\v2\Api::postServer} |
||
30 | * |
||
31 | * @return \OpenStack\Compute\v2\Models\Server |
||
32 | */ |
||
33 | public function createServer(array $options): Server |
||
37 | |||
38 | /** |
||
39 | * List servers. |
||
40 | 1 | * |
|
41 | * @param bool $detailed Determines whether detailed information will be returned. If FALSE is specified, only |
||
42 | 1 | * the ID, name and links attributes are returned, saving bandwidth. |
|
43 | 1 | * @param array $options {@see \OpenStack\Compute\v2\Api::getServers} |
|
44 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
45 | * |
||
46 | * @return \Generator |
||
47 | */ |
||
48 | public function listServers(bool $detailed = false, array $options = [], callable $mapFn = null): \Generator |
||
53 | |||
54 | /** |
||
55 | * Retrieve a server object without calling the remote API. Any values provided in the array will populate the |
||
56 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
57 | * and have the response populate the object, call {@see Server::retrieve}. For example: |
||
58 | 1 | * |
|
59 | * <code>$server = $service->getServer(['id' => '{serverId}']);</code> |
||
60 | 1 | * |
|
61 | 1 | * @param array $options An array of attributes that will be set on the {@see Server} object. The array keys need to |
|
62 | 1 | * correspond to the class public properties. |
|
63 | * |
||
64 | * @return \OpenStack\Compute\v2\Models\Server |
||
65 | */ |
||
66 | public function getServer(array $options = []): Server |
||
72 | |||
73 | 1 | /** |
|
74 | * List flavors. |
||
75 | 1 | * |
|
76 | * @param array $options {@see \OpenStack\Compute\v2\Api::getFlavors} |
||
77 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
78 | * @param bool $detailed Set to true to fetch flavors' details. |
||
79 | * |
||
80 | * @return \Generator |
||
81 | */ |
||
82 | public function listFlavors(array $options = [], callable $mapFn = null, bool $detailed = false): \Generator |
||
87 | |||
88 | 1 | /** |
|
89 | * Retrieve a flavor object without calling the remote API. Any values provided in the array will populate the |
||
90 | 1 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
|
91 | 1 | * and have the response populate the object, call {@see Flavor::retrieve}. |
|
92 | 1 | * |
|
93 | * @param array $options An array of attributes that will be set on the {@see Flavor} object. The array keys need to |
||
94 | * correspond to the class public properties. |
||
95 | * |
||
96 | * @return \OpenStack\Compute\v2\Models\Flavor |
||
97 | */ |
||
98 | public function getFlavor(array $options = []): Flavor |
||
104 | |||
105 | 1 | /** |
|
106 | * Create a new flavor resource. |
||
107 | * |
||
108 | * @param array $options {@see \OpenStack\Compute\v2\Api::postFlavors} |
||
109 | * |
||
110 | * @return Flavor |
||
111 | */ |
||
112 | public function createFlavor(array $options = []): Flavor |
||
116 | |||
117 | /** |
||
118 | 1 | * List images. |
|
119 | * |
||
120 | 1 | * @param array $options {@see \OpenStack\Compute\v2\Api::getImages} |
|
121 | 1 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
|
122 | 1 | * |
|
123 | * @return \Generator |
||
124 | */ |
||
125 | public function listImages(array $options = [], callable $mapFn = null): \Generator |
||
129 | |||
130 | /** |
||
131 | * Retrieve an image object without calling the remote API. Any values provided in the array will populate the |
||
132 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
133 | * and have the response populate the object, call {@see Image::retrieve}. |
||
134 | * |
||
135 | * @param array $options An array of attributes that will be set on the {@see Image} object. The array keys need to |
||
136 | * correspond to the class public properties. |
||
137 | * |
||
138 | * @return \OpenStack\Compute\v2\Models\Image |
||
139 | */ |
||
140 | public function getImage(array $options = []): Image |
||
146 | |||
147 | /** |
||
148 | * List key pairs. |
||
149 | * |
||
150 | * @param array $options {@see \OpenStack\Compute\v2\Api::getKeyPairs} |
||
151 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
152 | * |
||
153 | * @return \Generator |
||
154 | */ |
||
155 | public function listKeypairs(array $options = [], callable $mapFn = null): \Generator |
||
159 | |||
160 | /** |
||
161 | * Create or import keypair |
||
162 | * |
||
163 | * @param array $options |
||
164 | * |
||
165 | * @return Keypair |
||
166 | */ |
||
167 | public function createKeypair(array $options): Keypair |
||
171 | |||
172 | /** |
||
173 | * Get keypair |
||
174 | * |
||
175 | * @param array $options |
||
176 | * |
||
177 | * @return Keypair |
||
178 | */ |
||
179 | public function getKeypair(array $options = []): Keypair |
||
185 | |||
186 | /** |
||
187 | * Shows rate and absolute limits for the tenant |
||
188 | * |
||
189 | * @return Limit |
||
190 | */ |
||
191 | public function getLimits(): Limit |
||
197 | |||
198 | /** |
||
199 | * Shows summary statistics for all hypervisors over all compute nodes. |
||
200 | * |
||
201 | * @return HypervisorStatistic |
||
202 | */ |
||
203 | public function getHypervisorStatistics(): HypervisorStatistic |
||
209 | |||
210 | /** |
||
211 | * List hypervisors. |
||
212 | * |
||
213 | * @param bool $detailed Determines whether detailed information will be returned. If FALSE is specified, only |
||
214 | * the ID, name and links attributes are returned, saving bandwidth. |
||
215 | * @param array $options {@see \OpenStack\Compute\v2\Api::getHypervisors} |
||
216 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
217 | * |
||
218 | * @return \Generator |
||
219 | */ |
||
220 | public function listHypervisors(bool $detailed = false, array $options = [], callable $mapFn = null): \Generator |
||
225 | |||
226 | /** |
||
227 | * Shows details for a given hypervisor. |
||
228 | * |
||
229 | * @param array $options |
||
230 | * |
||
231 | * @return Hypervisor |
||
232 | */ |
||
233 | public function getHypervisor(array $options = []): Hypervisor |
||
238 | |||
239 | /** |
||
240 | * List hosts. |
||
241 | * |
||
242 | * @param array $options {@see \OpenStack\Compute\v2\Api::getHosts} |
||
243 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
244 | * |
||
245 | * @return \Generator |
||
246 | */ |
||
247 | public function listHosts(array $options = [], callable $mapFn = null): \Generator |
||
251 | |||
252 | /** |
||
253 | * Retrieve a host object without calling the remote API. Any values provided in the array will populate the |
||
254 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
255 | * and have the response populate the object, call {@see Host::retrieve}. For example: |
||
256 | * |
||
257 | * <code>$server = $service->getHost(['name' => '{name}']);</code> |
||
258 | * |
||
259 | * @param array $options An array of attributes that will be set on the {@see Host} object. The array keys need to |
||
260 | * correspond to the class public properties. |
||
261 | * |
||
262 | * @return \OpenStack\Compute\v2\Models\Host |
||
263 | */ |
||
264 | public function getHost(array $options = []): Host |
||
270 | |||
271 | /** |
||
272 | * List AZs |
||
273 | * |
||
274 | * @param array $options {@see \OpenStack\Compute\v2\Api::getAvailabilityZones} |
||
275 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
276 | * |
||
277 | * @return \Generator |
||
278 | */ |
||
279 | public function listAvailabilityZones(array $options = [], callable $mapFn = null): \Generator |
||
283 | |||
284 | /** |
||
285 | * Shows A Quota for a tenant |
||
286 | * |
||
287 | * @param string $tenantId |
||
288 | * @param bool $detailed |
||
289 | * |
||
290 | * @return QuotaSet |
||
291 | */ |
||
292 | public function getQuotaSet(string $tenantId, bool $detailed = false): QuotaSet |
||
299 | |||
300 | /** |
||
301 | * List host aggregates. |
||
302 | * |
||
303 | * @param array $options {@see \OpenStack\Compute\v2\Api::getAggregates} |
||
304 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
305 | * |
||
306 | * @return \Generator |
||
307 | */ |
||
308 | public function listAggregates(array $options = [], callable $mapFn = null): \Generator |
||
312 | |||
313 | /** |
||
314 | * Shows details for a given host aggregate. |
||
315 | * |
||
316 | * @param array $options |
||
317 | * |
||
318 | * @return Aggregate |
||
319 | */ |
||
320 | public function getAggregate(array $options = []): Aggregate |
||
325 | } |
||
326 |
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: