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 | protected function __construct(LoopInterface $loop) |
||
51 | |||
52 | /** |
||
53 | * @param LoopInterface $loop |
||
54 | * @return Pool |
||
55 | * @throws \Exception |
||
56 | */ |
||
57 | public static function getInstance(LoopInterface $loop = null) |
||
69 | |||
70 | /** |
||
71 | * @param $tableName |
||
72 | * @param $function |
||
73 | * @param array $arguments |
||
74 | * @return PromiseInterface |
||
75 | */ |
||
76 | public function call($tableName, $function, array $arguments) |
||
84 | |||
85 | /** |
||
86 | * @param $tableName |
||
87 | * @param $function |
||
88 | * @param array $arguments |
||
89 | * @return PromiseInterface |
||
90 | */ |
||
91 | protected function poolCall($tableName, $function, array $arguments) |
||
101 | |||
102 | /** |
||
103 | * @param $tableName |
||
104 | * @param $function |
||
105 | * @param array $arguments |
||
106 | * @return PromiseInterface |
||
107 | */ |
||
108 | protected function waitForPoolCall($tableName, $function, array $arguments) |
||
124 | |||
125 | /** |
||
126 | * @inheritDoc |
||
127 | */ |
||
128 | public function info() |
||
136 | } |
||
137 |
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: