1 | <?php declare(strict_types=1); |
||
16 | class Service extends AbstractService |
||
17 | { |
||
18 | /** |
||
19 | * Create a new network resource. |
||
20 | * |
||
21 | * @param array $options {@see \OpenStack\Networking\v2\Api::postNetwork} |
||
22 | * |
||
23 | * @return Network |
||
24 | 1 | */ |
|
25 | public function createNetwork(array $options): Network |
||
29 | |||
30 | /** |
||
31 | * Create a new network resources. |
||
32 | * |
||
33 | * @param array $options {@see \OpenStack\Networking\v2\Api::postNetworks} |
||
34 | * |
||
35 | * @return array |
||
36 | 1 | */ |
|
37 | public function createNetworks(array $options): array |
||
41 | |||
42 | /** |
||
43 | * Retrieve a network object without calling the remote API. Any values provided in the array will populate the |
||
44 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
45 | * and have the response populate the object, call {@see Network::retrieve}. |
||
46 | * |
||
47 | * @param string $id |
||
48 | * |
||
49 | * @return Network |
||
50 | 1 | */ |
|
51 | public function getNetwork(string $id): Network |
||
55 | |||
56 | /** |
||
57 | * List networks. |
||
58 | * |
||
59 | * @param array $options {@see \OpenStack\Networking\v2\Api::getNetworks} |
||
60 | * |
||
61 | * @return \Generator |
||
62 | 1 | */ |
|
63 | public function listNetworks(array $options = []): \Generator |
||
67 | |||
68 | /** |
||
69 | * Create a new subnet resource. |
||
70 | * |
||
71 | * @param array $options {@see \OpenStack\Networking\v2\Api::postSubnet} |
||
72 | * |
||
73 | * @return Subnet |
||
74 | 1 | */ |
|
75 | public function createSubnet(array $options): Subnet |
||
79 | |||
80 | /** |
||
81 | * Create a new subnet resources. |
||
82 | * |
||
83 | * @param array $options {@see \OpenStack\Networking\v2\Api::postSubnets} |
||
84 | * |
||
85 | * @return []Subnet |
||
86 | 1 | */ |
|
87 | public function createSubnets(array $options): array |
||
91 | |||
92 | /** |
||
93 | * Retrieve a subnet object without calling the remote API. Any values provided in the array will populate the |
||
94 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
95 | * and have the response populate the object, call {@see Subnet::retrieve}. |
||
96 | * |
||
97 | * @param string $id |
||
98 | * |
||
99 | * @return Subnet |
||
100 | 1 | */ |
|
101 | public function getSubnet(string $id): Subnet |
||
105 | |||
106 | /** |
||
107 | * List subnets. |
||
108 | * |
||
109 | * @param array $options {@see \OpenStack\Networking\v2\Api::getSubnets} |
||
110 | * |
||
111 | * @return \Generator |
||
112 | 1 | */ |
|
113 | public function listSubnets(array $options = []): \Generator |
||
117 | |||
118 | /** |
||
119 | * Create a new port resource. |
||
120 | * |
||
121 | * @param array $options {@see \OpenStack\Networking\v2\Api::postSinglePort} |
||
122 | * |
||
123 | * @return Port |
||
124 | 1 | */ |
|
125 | public function createPort(array $options): Port |
||
129 | |||
130 | /** |
||
131 | * Create new port resources. |
||
132 | * |
||
133 | * @param array $options {@see \OpenStack\Networking\v2\Api::postMultiplePorts} |
||
134 | * |
||
135 | * @return []Port |
||
136 | 1 | */ |
|
137 | public function createPorts(array $options): array |
||
141 | |||
142 | /** |
||
143 | * Retrieve a subnet object without calling the remote API. Any values provided in the array will populate the |
||
144 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
145 | * and have the response populate the object, call {@see Port::retrieve}. |
||
146 | * |
||
147 | * @param string $id |
||
148 | * |
||
149 | * @return Port |
||
150 | 1 | */ |
|
151 | public function getPort(string $id): Port |
||
155 | |||
156 | /** |
||
157 | * List ports. |
||
158 | * |
||
159 | * @param array $options {@see \OpenStack\Networking\v2\Api::getPorts} |
||
160 | * |
||
161 | * @return \Generator |
||
162 | 1 | */ |
|
163 | public function listPorts(array $options = []): \Generator |
||
167 | |||
168 | /** |
||
169 | * Lists quotas for projects with non-default quota values. |
||
170 | * |
||
171 | * @return \Generator |
||
172 | */ |
||
173 | public function listQuotas(): \Generator |
||
177 | |||
178 | /** |
||
179 | * Lists quotas for a project. |
||
180 | * |
||
181 | * Retrieve a quota object without calling the remote API. Any values provided in the array will populate the |
||
182 | * empty object, allowing you greater control without the expense of network transactions. To call the remote API |
||
183 | * and have the response populate the object, call {@see Quota::retrieve}. |
||
184 | * |
||
185 | * @param string $tenantId |
||
186 | * |
||
187 | * @return Quota |
||
188 | */ |
||
189 | public function getQuota(string $tenantId): Quota |
||
193 | |||
194 | /** |
||
195 | * Lists default quotas for a project |
||
196 | * |
||
197 | * @param string $tenantId |
||
198 | * |
||
199 | * @return Quota |
||
200 | */ |
||
201 | public function getDefaultQuota(string $tenantId): Quota |
||
208 | } |
||
209 |
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: