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