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