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 string |
||
71 | */ |
||
72 | public $healthmonitorId; |
||
73 | |||
74 | protected $resourcesKey = 'pools'; |
||
75 | protected $resourceKey = 'pool'; |
||
76 | |||
77 | protected $aliases = [ |
||
78 | 'tenant_id' => 'tenantId', |
||
79 | 'admin_state_up' => 'adminStateUp', |
||
80 | 'lb_algorithm' => 'lbAlgorithm', |
||
81 | 'session_persistence' => 'sessionPersistence', |
||
82 | 'healthmonitor_id' => 'healthmonitorId', |
||
83 | 'loadbalancer_id' => 'loadbalancerId' |
||
84 | ]; |
||
85 | |||
86 | /** |
||
87 | * {@inheritDoc} |
||
88 | */ |
||
89 | public function create(array $userOptions): Creatable |
||
94 | |||
95 | /** |
||
96 | * {@inheritDoc} |
||
97 | */ |
||
98 | public function retrieve() |
||
103 | |||
104 | /** |
||
105 | * {@inheritDoc} |
||
106 | */ |
||
107 | public function update() |
||
112 | |||
113 | /** |
||
114 | * {@inheritDoc} |
||
115 | */ |
||
116 | public function delete() |
||
120 | |||
121 | /** |
||
122 | * Add a member to this pool |
||
123 | * |
||
124 | * @param array $userOptions |
||
125 | */ |
||
126 | public function addMember(array $userOptions = []): LoadbalancerMember |
||
131 | |||
132 | /** |
||
133 | * Get an instance of a member |
||
134 | * |
||
135 | * @param string $member_id |
||
136 | * @return LoadbalancerMember |
||
137 | */ |
||
138 | public function getMember(string $member_id): LoadbalancerMember |
||
142 | |||
143 | /** |
||
144 | * Delete a member |
||
145 | * |
||
146 | * @param string $member_id |
||
147 | */ |
||
148 | public function deleteMember(string $member_id) |
||
152 | |||
153 | /** |
||
154 | * Add a healthmonitor to this load balancer pool |
||
155 | * |
||
156 | * @param array $userOptions |
||
157 | * @return LoadbalancerHealthmonitor |
||
158 | */ |
||
159 | public function addHealthmonitor(array $userOptions = []): LoadbalancerHealthmonitor |
||
164 | } |
||
165 |
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: