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 |
||
| 26 | class HorizonServiceProvider extends ServiceProvider |
||
| 27 | { |
||
| 28 | /** |
||
| 29 | * Loads the package's configuration and provides configuration values. |
||
| 30 | * |
||
| 31 | * @var ConfigurationLoader |
||
| 32 | */ |
||
| 33 | protected $config; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Create a new service provider instance. |
||
| 37 | * |
||
| 38 | * @param Container $app The current Laravel/Lumen application |
||
| 39 | * instance. |
||
| 40 | * @param ConfigurationLoader $config Loads the package's configuration and |
||
|
|
|||
| 41 | * provides configuration values. |
||
| 42 | */ |
||
| 43 | public function __construct( |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Configure the package for use with Laravel Horizon. |
||
| 58 | * |
||
| 59 | * @return void |
||
| 60 | */ |
||
| 61 | public function register() |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Sets the Horizon Redis Sentinel connection configuration. |
||
| 82 | * |
||
| 83 | * @return void |
||
| 84 | */ |
||
| 85 | protected function createHorizonConnectionConfiguration() |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Copy the Redis Sentinel connection configuration to use for Horizon |
||
| 98 | * connections from the connection specified by "horizon.use". |
||
| 99 | * |
||
| 100 | * @return array The configuration matching the connection name specified |
||
| 101 | * by the "horizon.use" config directive. |
||
| 102 | * |
||
| 103 | * @throws RuntimeException If no Redis Sentinel connection matches the |
||
| 104 | * name declared by "horizon.use". |
||
| 105 | */ |
||
| 106 | protected function getSelectedConnectionConfiguration() |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Determine whether the package needs to override the Redis service |
||
| 122 | * injected into Horizon classes with the Sentinel service. |
||
| 123 | * |
||
| 124 | * @return bool True if configured as such and the package doesn't already |
||
| 125 | * override the application's Redis API. |
||
| 126 | */ |
||
| 127 | protected function shouldRebindHorizonRedisFactory() |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Add contextual bindings for Horizon's services that inject the package's |
||
| 137 | * Redis Sentinel manager. |
||
| 138 | * |
||
| 139 | * @return void |
||
| 140 | */ |
||
| 141 | protected function rebindHorizonRedisFactory() |
||
| 155 | |||
| 156 | /** |
||
| 157 | * Add "redis-sentinel" as an available queue connection driver option to |
||
| 158 | * the Laravel queue manager using Horizon's modified Redis connector. |
||
| 159 | * |
||
| 160 | * @return void |
||
| 161 | */ |
||
| 162 | View Code Duplication | protected function addHorizonSentinelQueueConnector() |
|
| 170 | } |
||
| 171 |
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.