Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
27 | class RedisSentinelServiceProvider extends ServiceProvider |
||
28 | { |
||
29 | /** |
||
30 | * Loads the package's configuration and provides configuration values. |
||
31 | * |
||
32 | * @var ConfigurationLoader |
||
33 | */ |
||
34 | protected $config; |
||
35 | |||
36 | /** |
||
37 | * Boot the service by registering extensions with Laravel's cache, queue, |
||
38 | * and session managers for the "redis-sentinel" driver. |
||
39 | * |
||
40 | * @return void |
||
41 | */ |
||
42 | public function boot() |
||
57 | |||
58 | /** |
||
59 | * Bind the "redis-sentinel" database driver to the application service |
||
60 | * container. |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | public function register() |
||
77 | |||
78 | /** |
||
79 | * Register the core Redis Sentinel connection manager. |
||
80 | * |
||
81 | * @return void |
||
82 | */ |
||
83 | protected function registerServices() |
||
99 | |||
100 | /** |
||
101 | * Replace the standard Laravel Redis service with the Redis Sentinel |
||
102 | * database driver so all Redis operations use Sentinel connections. |
||
103 | * |
||
104 | * @return void |
||
105 | */ |
||
106 | protected function registerOverrides() |
||
116 | |||
117 | /** |
||
118 | * Extend each of the Laravel services this package supports with the |
||
119 | * corresponding 'redis-sentinel' driver. |
||
120 | * |
||
121 | * @return void |
||
122 | */ |
||
123 | protected function bootComponentDrivers() |
||
140 | |||
141 | /** |
||
142 | * Remove the standard Laravel Redis service from the bound deferred |
||
143 | * services so they don't overwrite Redis Sentinel registrations. |
||
144 | * |
||
145 | * @return void |
||
146 | */ |
||
147 | protected function removeDeferredRedisServices() |
||
160 | |||
161 | /** |
||
162 | * Add "redis-sentinel" as an available broadcaster option to the Laravel |
||
163 | * event broadcasting manager. |
||
164 | * |
||
165 | * @return void |
||
166 | */ |
||
167 | protected function addRedisSentinelBroadcaster() |
||
177 | |||
178 | /** |
||
179 | * Add "redis-sentinel" as an available cache store option to the Laravel |
||
180 | * cache manager. |
||
181 | * |
||
182 | * @return void |
||
183 | */ |
||
184 | protected function addRedisSentinelCacheStore() |
||
197 | |||
198 | /** |
||
199 | * Add "redis-sentinel" as an available driver option to the Laravel |
||
200 | * session manager. |
||
201 | * |
||
202 | * @return void |
||
203 | */ |
||
204 | protected function addRedisSentinelSessionHandler() |
||
216 | |||
217 | /** |
||
218 | * Add "redis-sentinel" as an available queue connection driver option to |
||
219 | * the Laravel queue manager. |
||
220 | * |
||
221 | * @return void |
||
222 | */ |
||
223 | View Code Duplication | protected function addRedisSentinelQueueConnector() |
|
231 | } |
||
232 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: