1 | <?php declare(strict_types=1); |
||
20 | class Service extends AbstractService |
||
21 | { |
||
22 | /** |
||
23 | * Create a new server resource. This operation will provision a new virtual machine on a host chosen by your |
||
24 | * service API. |
||
25 | 1 | * |
|
26 | * @param array $options {@see \OpenStack\Compute\v2\Api::postServer} |
||
27 | 1 | * |
|
28 | * @return \OpenStack\Compute\v2\Models\Server |
||
29 | */ |
||
30 | public function createServer(array $options): Server |
||
34 | |||
35 | /** |
||
36 | * List servers. |
||
37 | * |
||
38 | * @param bool $detailed Determines whether detailed information will be returned. If FALSE is specified, only |
||
39 | * the ID, name and links attributes are returned, saving bandwidth. |
||
40 | 1 | * @param array $options {@see \OpenStack\Compute\v2\Api::getServers} |
|
41 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
42 | 1 | * |
|
43 | 1 | * @return \Generator |
|
44 | */ |
||
45 | public function listServers(bool $detailed = false, array $options = [], callable $mapFn = null): \Generator |
||
50 | |||
51 | /** |
||
52 | * Retrieve a server object without calling the remote API. Any values provided in the array will populate the |
||
53 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
54 | * and have the response populate the object, call {@see Server::retrieve}. For example: |
||
55 | * |
||
56 | * <code>$server = $service->getServer(['id' => '{serverId}']);</code> |
||
57 | * |
||
58 | 1 | * @param array $options An array of attributes that will be set on the {@see Server} object. The array keys need to |
|
59 | * correspond to the class public properties. |
||
60 | 1 | * |
|
61 | 1 | * @return \OpenStack\Compute\v2\Models\Server |
|
62 | 1 | */ |
|
63 | public function getServer(array $options = []): Server |
||
69 | |||
70 | /** |
||
71 | * List flavors. |
||
72 | * |
||
73 | 1 | * @param array $options {@see \OpenStack\Compute\v2\Api::getFlavors} |
|
74 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
75 | 1 | * |
|
76 | * @return \Generator |
||
77 | */ |
||
78 | public function listFlavors(array $options = [], callable $mapFn = null): \Generator |
||
82 | |||
83 | /** |
||
84 | * Retrieve a flavor object without calling the remote API. Any values provided in the array will populate the |
||
85 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
86 | * and have the response populate the object, call {@see Flavor::retrieve}. |
||
87 | * |
||
88 | 1 | * @param array $options An array of attributes that will be set on the {@see Flavor} object. The array keys need to |
|
89 | * correspond to the class public properties. |
||
90 | 1 | * |
|
91 | 1 | * @return \OpenStack\Compute\v2\Models\Flavor |
|
92 | 1 | */ |
|
93 | public function getFlavor(array $options = []): Flavor |
||
99 | |||
100 | /** |
||
101 | * Create a new flavor resource. |
||
102 | * |
||
103 | 1 | * @param array $options {@see \OpenStack\Compute\v2\Api::postFlavors} |
|
104 | * |
||
105 | 1 | * @return Flavor |
|
106 | */ |
||
107 | public function createFlavor(array $options = []): Flavor |
||
111 | |||
112 | /** |
||
113 | * List images. |
||
114 | * |
||
115 | * @param array $options {@see \OpenStack\Compute\v2\Api::getImages} |
||
116 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
117 | * |
||
118 | 1 | * @return \Generator |
|
119 | */ |
||
120 | 1 | public function listImages(array $options = [], callable $mapFn = null): \Generator |
|
124 | |||
125 | /** |
||
126 | * Retrieve an image object without calling the remote API. Any values provided in the array will populate the |
||
127 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
128 | * and have the response populate the object, call {@see Image::retrieve}. |
||
129 | * |
||
130 | * @param array $options An array of attributes that will be set on the {@see Image} object. The array keys need to |
||
131 | * correspond to the class public properties. |
||
132 | * |
||
133 | * @return \OpenStack\Compute\v2\Models\Image |
||
134 | */ |
||
135 | public function getImage(array $options = []): Image |
||
141 | |||
142 | /** |
||
143 | * List key pairs. |
||
144 | * |
||
145 | * @param array $options {@see \OpenStack\Compute\v2\Api::getKeyPairs} |
||
146 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
147 | * |
||
148 | * @return \Generator |
||
149 | */ |
||
150 | public function listKeypairs(array $options = [], callable $mapFn = null): \Generator |
||
154 | |||
155 | /** |
||
156 | * Create or import keypair |
||
157 | * |
||
158 | * @param array $options |
||
159 | * |
||
160 | * @return Keypair |
||
161 | */ |
||
162 | public function createKeypair(array $options): Keypair |
||
166 | |||
167 | /** |
||
168 | * Get keypair |
||
169 | * |
||
170 | * @param array $options |
||
171 | * |
||
172 | * @return Keypair |
||
173 | */ |
||
174 | public function getKeypair(array $options = []): Keypair |
||
180 | |||
181 | /** |
||
182 | * Shows rate and absolute limits for the tenant |
||
183 | * |
||
184 | * @return Limit |
||
185 | */ |
||
186 | public function getLimits(): Limit |
||
192 | |||
193 | /** |
||
194 | * Shows summary statistics for all hypervisors over all compute nodes. |
||
195 | * |
||
196 | * @return HypervisorStatistic |
||
197 | */ |
||
198 | public function getHypervisorStatistics(): HypervisorStatistic |
||
204 | |||
205 | /** |
||
206 | * List hypervisors. |
||
207 | * |
||
208 | * @param bool $detailed Determines whether detailed information will be returned. If FALSE is specified, only |
||
209 | * the ID, name and links attributes are returned, saving bandwidth. |
||
210 | * @param array $options {@see \OpenStack\Compute\v2\Api::getHypervisors} |
||
211 | * @param callable $mapFn A callable function that will be invoked on every iteration of the list. |
||
212 | * |
||
213 | * @return \Generator |
||
214 | */ |
||
215 | public function listHypervisors(bool $detailed = false, array $options = [], callable $mapFn = null): \Generator |
||
220 | |||
221 | /** |
||
222 | * Shows details for a given hypervisor. |
||
223 | * |
||
224 | * @param array $options |
||
225 | * |
||
226 | * @return Hypervisor |
||
227 | */ |
||
228 | public function getHypervisor(array $options = []): Hypervisor |
||
233 | |||
234 | /** |
||
235 | * Shows A Quota for a tenant |
||
236 | * |
||
237 | * @param string $tenantId |
||
238 | * @param bool $detailed |
||
239 | * |
||
240 | * @return QuotaSet |
||
241 | */ |
||
242 | public function getQuotaSet(string $tenantId, bool $detailed = false): QuotaSet |
||
249 | } |
||
250 |
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: