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 |
||
28 | class HorizonServiceProvider extends ServiceProvider |
||
29 | { |
||
30 | /** |
||
31 | * Loads the package's configuration and provides configuration values. |
||
32 | * |
||
33 | * @var ConfigurationLoader |
||
34 | */ |
||
35 | protected $config; |
||
36 | |||
37 | /** |
||
38 | * Create a new service provider instance. |
||
39 | * |
||
40 | * @param Container $app The current Laravel/Lumen application |
||
41 | * instance. |
||
42 | * @param ConfigurationLoader $config Loads the package's configuration and |
||
|
|||
43 | * provides configuration values. |
||
44 | */ |
||
45 | public function __construct( |
||
57 | |||
58 | /** |
||
59 | * Set up any additional components needed for Horizon. |
||
60 | * |
||
61 | * @return void |
||
62 | */ |
||
63 | public function boot() |
||
71 | |||
72 | /** |
||
73 | * Configure the package's services for use with Laravel Horizon. |
||
74 | * |
||
75 | * @return void |
||
76 | */ |
||
77 | public function register() |
||
91 | |||
92 | /** |
||
93 | * Register the core Redis Sentinel connection manager if not already bound |
||
94 | * (for using this service provider by itself). |
||
95 | * |
||
96 | * @return void |
||
97 | */ |
||
98 | protected function registerServices() |
||
108 | |||
109 | /** |
||
110 | * Determine whether the package needs to override the Redis service |
||
111 | * injected into Horizon classes with the Sentinel service. |
||
112 | * |
||
113 | * @return bool True if configured as such and the package doesn't already |
||
114 | * override the application's Redis API. |
||
115 | */ |
||
116 | protected function shouldRebindHorizonRedisFactory() |
||
128 | |||
129 | /** |
||
130 | * Add contextual bindings for Horizon's services that inject the package's |
||
131 | * Redis Sentinel manager. |
||
132 | * |
||
133 | * @return void |
||
134 | */ |
||
135 | protected function rebindHorizonRedisFactory() |
||
149 | |||
150 | /** |
||
151 | * Add "redis-sentinel" as an available queue connection driver option to |
||
152 | * the Laravel queue manager using Horizon's modified Redis connector. |
||
153 | * |
||
154 | * @return void |
||
155 | */ |
||
156 | View Code Duplication | protected function addHorizonSentinelQueueConnector() |
|
164 | } |
||
165 |
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.