1 | <?php declare(strict_types=1); |
||
17 | class Service extends AbstractService |
||
18 | { |
||
19 | /** |
||
20 | * Retrieves a collection of \OpenStack\Metric\v1\Gnocchi\Models\ResourceType type in a generator format. |
||
21 | * |
||
22 | * @return \Generator |
||
23 | */ |
||
24 | public function listResourceTypes(): \Generator |
||
28 | |||
29 | /** |
||
30 | * Retrieves a collection of \OpenStack\Metric\v1\Gnocchi\Models\Resource type in a generator format. |
||
31 | * |
||
32 | * @param array $options {@see \OpenStack\Metric\v1\Gnocchi\Api::getResources} |
||
33 | * |
||
34 | * @return \Generator |
||
35 | */ |
||
36 | public function listResources(array $options = []): \Generator |
||
42 | |||
43 | /** |
||
44 | * Retrieves a Resource object and populates its unique identifier object. This operation will not perform a GET or |
||
45 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
46 | * |
||
47 | * @param array $options |
||
48 | * |
||
49 | * @return Resource |
||
50 | */ |
||
51 | public function getResource(array $options = []): Resource |
||
61 | |||
62 | /** |
||
63 | * Retrieves a collection of \OpenStack\Metric\v1\Gnocchi\Models\Resource type in a generator format. |
||
64 | * |
||
65 | * @param array $options {@see \OpenStack\Metric\v1\Gnocchi\Api::searchResources} |
||
66 | * |
||
67 | * @return \Generator |
||
68 | */ |
||
69 | public function searchResources(array $options = []): \Generator |
||
89 | |||
90 | /** |
||
91 | * Retrieves a Metric object and populates its unique identifier object. This operation will not perform a GET or |
||
92 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
93 | * |
||
94 | * @param string $id |
||
95 | * |
||
96 | * @return Metric |
||
97 | */ |
||
98 | public function getMetric(string $id): Metric |
||
106 | |||
107 | /** |
||
108 | * Retrieves a collection of Metric type in a generator format. |
||
109 | * |
||
110 | * @param array $options {@see \OpenStack\Metric\v1\Gnocchi\Api::getMetrics} |
||
111 | * |
||
112 | * @return \Generator |
||
113 | */ |
||
114 | public function listMetrics(array $options = []): \Generator |
||
118 | |||
119 | /** |
||
120 | * If options does not have type, this will inject $options['type'] = 'generic' |
||
121 | * |
||
122 | * @internal |
||
123 | * @param array $options |
||
124 | */ |
||
125 | private function injectGenericType(array &$options) |
||
131 | } |
||
132 |
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: