1 | <?php declare(strict_types=1); |
||
18 | class LoadBalancerPool extends OperatorResource implements Creatable, Retrievable, Updateable, Deletable |
||
19 | { |
||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | public $name; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | public $description; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | public $id; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | public $tenantId; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | public $protocol; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | public $lbAlgorithm; |
||
49 | |||
50 | /** |
||
51 | * @var array |
||
52 | */ |
||
53 | public $sessionPersistence; |
||
54 | |||
55 | /** |
||
56 | * @var boolean |
||
57 | */ |
||
58 | public $adminStateUp; |
||
59 | |||
60 | /** |
||
61 | * @var LoadBalancerListener[] |
||
62 | */ |
||
63 | public $listeners; |
||
64 | |||
65 | /** |
||
66 | * @var LoadBalancerMember[] |
||
67 | */ |
||
68 | public $members; |
||
69 | |||
70 | /** |
||
71 | * @var LoadBalancerHealthMonitor[] |
||
72 | */ |
||
73 | public $healthmonitors; |
||
74 | |||
75 | /** |
||
76 | * @var string |
||
77 | */ |
||
78 | public $healthmonitorId; |
||
79 | |||
80 | /** |
||
81 | * @var string |
||
82 | */ |
||
83 | public $operatingStatus; |
||
84 | |||
85 | /** |
||
86 | * @var string |
||
87 | */ |
||
88 | public $provisioningStatus; |
||
89 | |||
90 | protected $resourcesKey = 'pools'; |
||
91 | protected $resourceKey = 'pool'; |
||
92 | |||
93 | protected $aliases = [ |
||
94 | 'tenant_id' => 'tenantId', |
||
95 | 'admin_state_up' => 'adminStateUp', |
||
96 | 'lb_algorithm' => 'lbAlgorithm', |
||
97 | 'session_persistence' => 'sessionPersistence', |
||
98 | 'healthmonitor_id' => 'healthmonitorId', |
||
99 | 'loadbalancer_id' => 'loadbalancerId', |
||
100 | 'operating_status' => 'operatingStatus', |
||
101 | 'provisioning_status' => 'provisioningStatus', |
||
102 | ]; |
||
103 | |||
104 | /** |
||
105 | * @inheritdoc |
||
106 | */ |
||
107 | protected function getAliases(): array |
||
108 | { |
||
109 | return parent::getAliases() + [ |
||
110 | 'listeners' => new Alias('listeners', LoadBalancerListener::class, true), |
||
111 | 'members' => new Alias('members', LoadBalancerMember::class, true), |
||
112 | 'healthmonitors' => new Alias('healthmonitors', LoadBalancerHealthMonitor::class, true) |
||
113 | ]; |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * {@inheritDoc} |
||
118 | */ |
||
119 | public function create(array $userOptions): Creatable |
||
124 | |||
125 | /** |
||
126 | * {@inheritDoc} |
||
127 | */ |
||
128 | public function retrieve() |
||
133 | |||
134 | /** |
||
135 | * {@inheritDoc} |
||
136 | */ |
||
137 | public function update() |
||
142 | |||
143 | /** |
||
144 | * {@inheritDoc} |
||
145 | */ |
||
146 | public function delete() |
||
150 | |||
151 | /** |
||
152 | * Add a member to this pool |
||
153 | * |
||
154 | * @param array $userOptions |
||
155 | */ |
||
156 | public function addMember(array $userOptions = []): LoadBalancerMember |
||
161 | |||
162 | /** |
||
163 | * Get an instance of a member |
||
164 | * |
||
165 | * @param string $memberId |
||
166 | * @return LoadBalancerMember |
||
167 | */ |
||
168 | public function getMember(string $memberId): LoadBalancerMember |
||
172 | |||
173 | /** |
||
174 | * Delete a member |
||
175 | * |
||
176 | * @param string $memberId |
||
177 | */ |
||
178 | public function deleteMember(string $memberId) |
||
182 | |||
183 | /** |
||
184 | * Add a healthmonitor to this load balancer pool |
||
185 | * |
||
186 | * @param array $userOptions |
||
187 | * @return LoadBalancerHealthMonitor |
||
188 | */ |
||
189 | public function addHealthMonitor(array $userOptions = []): LoadBalancerHealthMonitor |
||
194 | } |
||
195 |
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: