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 | * List flavors. |
|
74 | * |
||
75 | 1 | * @param array $options {@see \OpenStack\Compute\v2\Api::getFlavors} |
|
76 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
77 | * |
||
78 | * @return \Generator |
||
79 | */ |
||
80 | public function listFlavors(array $options = [], callable $mapFn = null): \Generator |
||
84 | |||
85 | /** |
||
86 | * Retrieve a flavor object without calling the remote API. Any values provided in the array will populate the |
||
87 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
88 | 1 | * and have the response populate the object, call {@see Flavor::retrieve}. |
|
89 | * |
||
90 | 1 | * @param array $options An array of attributes that will be set on the {@see Flavor} object. The array keys need to |
|
91 | 1 | * correspond to the class public properties. |
|
92 | 1 | * |
|
93 | * @return \OpenStack\Compute\v2\Models\Flavor |
||
94 | */ |
||
95 | public function getFlavor(array $options = []): Flavor |
||
101 | |||
102 | /** |
||
103 | 1 | * Create a new flavor resource. |
|
104 | * |
||
105 | 1 | * @param array $options {@see \OpenStack\Compute\v2\Api::postFlavors} |
|
106 | * |
||
107 | * @return Flavor |
||
108 | */ |
||
109 | public function createFlavor(array $options = []): Flavor |
||
113 | |||
114 | /** |
||
115 | * List images. |
||
116 | * |
||
117 | * @param array $options {@see \OpenStack\Compute\v2\Api::getImages} |
||
118 | 1 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
|
119 | * |
||
120 | 1 | * @return \Generator |
|
121 | 1 | */ |
|
122 | 1 | public function listImages(array $options = [], callable $mapFn = null): \Generator |
|
126 | |||
127 | /** |
||
128 | * Retrieve an image object without calling the remote API. Any values provided in the array will populate the |
||
129 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
130 | * and have the response populate the object, call {@see Image::retrieve}. |
||
131 | * |
||
132 | * @param array $options An array of attributes that will be set on the {@see Image} object. The array keys need to |
||
133 | * correspond to the class public properties. |
||
134 | * |
||
135 | * @return \OpenStack\Compute\v2\Models\Image |
||
136 | */ |
||
137 | public function getImage(array $options = []): Image |
||
143 | |||
144 | /** |
||
145 | * List key pairs. |
||
146 | * |
||
147 | * @param array $options {@see \OpenStack\Compute\v2\Api::getKeyPairs} |
||
148 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
149 | * |
||
150 | * @return \Generator |
||
151 | */ |
||
152 | public function listKeypairs(array $options = [], callable $mapFn = null): \Generator |
||
156 | |||
157 | /** |
||
158 | * Create or import keypair |
||
159 | * |
||
160 | * @param array $options |
||
161 | * |
||
162 | * @return Keypair |
||
163 | */ |
||
164 | public function createKeypair(array $options): Keypair |
||
168 | |||
169 | /** |
||
170 | * Get keypair |
||
171 | * |
||
172 | * @param array $options |
||
173 | * |
||
174 | * @return Keypair |
||
175 | */ |
||
176 | public function getKeypair(array $options = []): Keypair |
||
182 | |||
183 | /** |
||
184 | * Shows rate and absolute limits for the tenant |
||
185 | * |
||
186 | * @return Limit |
||
187 | */ |
||
188 | public function getLimits(): Limit |
||
194 | |||
195 | /** |
||
196 | * Shows summary statistics for all hypervisors over all compute nodes. |
||
197 | * |
||
198 | * @return HypervisorStatistic |
||
199 | */ |
||
200 | public function getHypervisorStatistics(): HypervisorStatistic |
||
206 | |||
207 | /** |
||
208 | * List hypervisors. |
||
209 | * |
||
210 | * @param bool $detailed Determines whether detailed information will be returned. If FALSE is specified, only |
||
211 | * the ID, name and links attributes are returned, saving bandwidth. |
||
212 | * @param array $options {@see \OpenStack\Compute\v2\Api::getHypervisors} |
||
213 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
214 | * |
||
215 | * @return \Generator |
||
216 | */ |
||
217 | public function listHypervisors(bool $detailed = false, array $options = [], callable $mapFn = null): \Generator |
||
222 | |||
223 | /** |
||
224 | * Shows details for a given hypervisor. |
||
225 | * |
||
226 | * @param array $options |
||
227 | * |
||
228 | * @return Hypervisor |
||
229 | */ |
||
230 | public function getHypervisor(array $options = []): Hypervisor |
||
235 | |||
236 | /** |
||
237 | * List hosts. |
||
238 | * |
||
239 | * @param array $options {@see \OpenStack\Compute\v2\Api::getHosts} |
||
240 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
241 | * |
||
242 | * @return \Generator |
||
243 | */ |
||
244 | public function listHosts(array $options = [], callable $mapFn = null): \Generator |
||
248 | |||
249 | /** |
||
250 | * Retrieve a host object without calling the remote API. Any values provided in the array will populate the |
||
251 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
252 | * and have the response populate the object, call {@see Host::retrieve}. For example: |
||
253 | * |
||
254 | * <code>$server = $service->getHost(['name' => '{name}']);</code> |
||
255 | * |
||
256 | * @param array $options An array of attributes that will be set on the {@see Host} object. The array keys need to |
||
257 | * correspond to the class public properties. |
||
258 | * |
||
259 | * @return \OpenStack\Compute\v2\Models\Host |
||
260 | */ |
||
261 | public function getHost(array $options = []): Host |
||
267 | |||
268 | /** |
||
269 | * List AZs |
||
270 | * |
||
271 | * @param array $options {@see \OpenStack\Compute\v2\Api::getAvailabiltyZones} |
||
272 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
273 | * |
||
274 | * @return \Generator |
||
275 | */ |
||
276 | public function listAvailabilityZones(array $options = [], callable $mapFn = null): \Generator |
||
280 | |||
281 | /** |
||
282 | * Shows A Quota for a tenant |
||
283 | * |
||
284 | * @param string $tenantId |
||
285 | * @param bool $detailed |
||
286 | * |
||
287 | * @return QuotaSet |
||
288 | */ |
||
289 | public function getQuotaSet(string $tenantId, bool $detailed = false): QuotaSet |
||
296 | } |
||
297 |
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: