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 | * Records whether this provider has already been booted (eg. via auto-boot) |
||
| 38 | * |
||
| 39 | * @var boolean |
||
| 40 | */ |
||
| 41 | private $isBooted = false; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Boot the service by registering extensions with Laravel's cache, queue, |
||
| 45 | * and session managers for the "redis-sentinel" driver. |
||
| 46 | * |
||
| 47 | * @return void |
||
| 48 | */ |
||
| 49 | public function boot() |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Bind the "redis-sentinel" database driver to the application service |
||
| 76 | * container. |
||
| 77 | * |
||
| 78 | * @return void |
||
| 79 | */ |
||
| 80 | public function register() |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Register the core Redis Sentinel connection manager. |
||
| 103 | * |
||
| 104 | * @return void |
||
| 105 | */ |
||
| 106 | protected function registerServices() |
||
| 118 | |||
| 119 | /** |
||
| 120 | * Replace the standard Laravel Redis service with the Redis Sentinel |
||
| 121 | * database driver so all Redis operations use Sentinel connections. |
||
| 122 | * |
||
| 123 | * @return void |
||
| 124 | */ |
||
| 125 | protected function registerOverrides() |
||
| 135 | |||
| 136 | /** |
||
| 137 | * Extend each of the Laravel services this package supports with the |
||
| 138 | * corresponding 'redis-sentinel' driver. |
||
| 139 | * |
||
| 140 | * @return void |
||
| 141 | */ |
||
| 142 | protected function bootComponentDrivers() |
||
| 159 | |||
| 160 | /** |
||
| 161 | * Remove the standard Laravel Redis service from the bound deferred |
||
| 162 | * services so they don't overwrite Redis Sentinel registrations. |
||
| 163 | * |
||
| 164 | * @return void |
||
| 165 | */ |
||
| 166 | protected function removeDeferredRedisServices() |
||
| 179 | |||
| 180 | /** |
||
| 181 | * Add "redis-sentinel" as an available broadcaster option to the Laravel |
||
| 182 | * event broadcasting manager. |
||
| 183 | * |
||
| 184 | * @return void |
||
| 185 | */ |
||
| 186 | protected function addRedisSentinelBroadcaster() |
||
| 196 | |||
| 197 | /** |
||
| 198 | * Add "redis-sentinel" as an available cache store option to the Laravel |
||
| 199 | * cache manager. |
||
| 200 | * |
||
| 201 | * @return void |
||
| 202 | */ |
||
| 203 | protected function addRedisSentinelCacheStore() |
||
| 216 | |||
| 217 | /** |
||
| 218 | * Add "redis-sentinel" as an available driver option to the Laravel |
||
| 219 | * session manager. |
||
| 220 | * |
||
| 221 | * @return void |
||
| 222 | */ |
||
| 223 | protected function addRedisSentinelSessionHandler() |
||
| 235 | |||
| 236 | /** |
||
| 237 | * Add "redis-sentinel" as an available queue connection driver option to |
||
| 238 | * the Laravel queue manager. |
||
| 239 | * |
||
| 240 | * @return void |
||
| 241 | */ |
||
| 242 | View Code Duplication | protected function addRedisSentinelQueueConnector() |
|
| 250 | } |
||
| 251 |
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: