1 | <?php declare(strict_types=1); |
||
17 | class LoadBalancerPool extends OperatorResource implements Creatable, Retrievable, Updateable, Deletable |
||
18 | { |
||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | public $name; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | public $description; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | public $id; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | public $tenantId; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | public $protocol; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | public $lbAlgorithm; |
||
48 | |||
49 | /** |
||
50 | * @var array |
||
51 | */ |
||
52 | public $sessionPersistence; |
||
53 | |||
54 | /** |
||
55 | * @var boolean |
||
56 | */ |
||
57 | public $adminStateUp; |
||
58 | |||
59 | /** |
||
60 | * @var LoadBalancerListener[] |
||
61 | */ |
||
62 | public $listeners; |
||
63 | |||
64 | /** |
||
65 | * @var LoadBalancerMember[] |
||
66 | */ |
||
67 | public $members; |
||
68 | |||
69 | /** |
||
70 | * @var LoadBalancerHealthMonitor[] |
||
71 | */ |
||
72 | public $healthmonitors; |
||
73 | |||
74 | /** |
||
75 | * @var string |
||
76 | */ |
||
77 | public $healthmonitorId; |
||
78 | |||
79 | /** |
||
80 | * @var string |
||
81 | */ |
||
82 | public $operatingStatus; |
||
83 | |||
84 | /** |
||
85 | * @var string |
||
86 | */ |
||
87 | public $provisioningStatus; |
||
88 | |||
89 | protected $resourcesKey = 'pools'; |
||
90 | protected $resourceKey = 'pool'; |
||
91 | |||
92 | protected $aliases = [ |
||
93 | 'tenant_id' => 'tenantId', |
||
94 | 'admin_state_up' => 'adminStateUp', |
||
95 | 'lb_algorithm' => 'lbAlgorithm', |
||
96 | 'session_persistence' => 'sessionPersistence', |
||
97 | 'healthmonitor_id' => 'healthmonitorId', |
||
98 | 'loadbalancer_id' => 'loadbalancerId', |
||
99 | 'operating_status' => 'operatingStatus', |
||
100 | 'provisioning_status' => 'provisioningStatus' |
||
101 | ]; |
||
102 | |||
103 | /** |
||
104 | * {@inheritDoc} |
||
105 | */ |
||
106 | public function create(array $userOptions): Creatable |
||
111 | |||
112 | /** |
||
113 | * {@inheritDoc} |
||
114 | */ |
||
115 | public function retrieve() |
||
120 | |||
121 | /** |
||
122 | * {@inheritDoc} |
||
123 | */ |
||
124 | public function update() |
||
129 | |||
130 | /** |
||
131 | * {@inheritDoc} |
||
132 | */ |
||
133 | public function delete() |
||
137 | |||
138 | /** |
||
139 | * Add a member to this pool |
||
140 | * |
||
141 | * @param array $userOptions |
||
142 | */ |
||
143 | public function addMember(array $userOptions = []): LoadBalancerMember |
||
148 | |||
149 | /** |
||
150 | * Get an instance of a member |
||
151 | * |
||
152 | * @param string $memberId |
||
153 | * @return LoadBalancerMember |
||
154 | */ |
||
155 | public function getMember(string $memberId): LoadBalancerMember |
||
159 | |||
160 | /** |
||
161 | * Delete a member |
||
162 | * |
||
163 | * @param string $memberId |
||
164 | */ |
||
165 | public function deleteMember(string $memberId) |
||
169 | |||
170 | /** |
||
171 | * Add a healthmonitor to this load balancer pool |
||
172 | * |
||
173 | * @param array $userOptions |
||
174 | * @return LoadBalancerHealthMonitor |
||
175 | */ |
||
176 | public function addHealthMonitor(array $userOptions = []): LoadBalancerHealthMonitor |
||
181 | } |
||
182 |
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: