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