1 | <?php |
||
21 | class Pool implements PoolUtilizerInterface |
||
22 | { |
||
23 | /** |
||
24 | * @var LoopInterface |
||
25 | */ |
||
26 | protected $loop; |
||
27 | |||
28 | /** |
||
29 | * @var PoolInfoInterface |
||
30 | */ |
||
31 | protected $pool; |
||
32 | |||
33 | /** |
||
34 | * @param LoopInterface $loop |
||
35 | */ |
||
36 | 1 | protected function __construct(LoopInterface $loop) |
|
51 | |||
52 | /** |
||
53 | * @param LoopInterface $loop |
||
54 | * @return Pool |
||
55 | * @throws \Exception |
||
56 | */ |
||
57 | 2 | public static function getInstance(LoopInterface $loop = null) |
|
69 | |||
70 | 18 | public static function reset() |
|
74 | |||
75 | /** |
||
76 | * @param $tableName |
||
77 | * @param $function |
||
78 | * @param array $arguments |
||
79 | * @return PromiseInterface |
||
80 | */ |
||
81 | public function call($tableName, $function, array $arguments) |
||
89 | |||
90 | /** |
||
91 | * @param $tableName |
||
92 | * @param $function |
||
93 | * @param array $arguments |
||
94 | * @return PromiseInterface |
||
95 | */ |
||
96 | protected function poolCall($tableName, $function, array $arguments) |
||
106 | |||
107 | /** |
||
108 | * @param $tableName |
||
109 | * @param $function |
||
110 | * @param array $arguments |
||
111 | * @return PromiseInterface |
||
112 | */ |
||
113 | 1 | protected function waitForPoolCall($tableName, $function, array $arguments) |
|
129 | |||
130 | /** |
||
131 | * @inheritDoc |
||
132 | */ |
||
133 | 1 | public function info() |
|
141 | } |
||
142 |
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: