1 | <?php |
||
63 | class Loader |
||
64 | { |
||
65 | /** |
||
66 | * The path to the package's default configuration file. |
||
67 | * |
||
68 | * @var string |
||
69 | */ |
||
70 | const CONFIG_PATH = __DIR__ . '/../../config/redis-sentinel.php'; |
||
71 | |||
72 | /** |
||
73 | * Indicates whether the current application runs the Lumen framework. |
||
74 | * |
||
75 | * @var bool |
||
76 | */ |
||
77 | public $isLumen; |
||
78 | |||
79 | /** |
||
80 | * Indicates whether the current application supports sessions. |
||
81 | * |
||
82 | * @var bool |
||
83 | */ |
||
84 | public $supportsSessions; |
||
85 | |||
86 | /** |
||
87 | * The current application instance that provides context and services |
||
88 | * used to load the appropriate configuration. |
||
89 | * |
||
90 | * @var LaravelApplication|LumenApplication |
||
91 | */ |
||
92 | private $app; |
||
93 | |||
94 | /** |
||
95 | * Used to fetch and set application configuration values. |
||
96 | * |
||
97 | * @var \Illuminate\Contracts\Config\Repository |
||
98 | */ |
||
99 | private $config; |
||
100 | |||
101 | /** |
||
102 | * Contains the set of configuration values used to configure the package |
||
103 | * as loaded from "config/redis-sentinel.php". Empty when the application's |
||
104 | * standard config files provide all the values needed to configure the |
||
105 | * package (such as when a developer provides a custom config). |
||
106 | * |
||
107 | * @var array |
||
108 | */ |
||
109 | private $packageConfig; |
||
110 | |||
111 | /** |
||
112 | * Initialize the configuration loader. Any actual loading occurs when |
||
113 | * calling the 'loadConfiguration()' method. |
||
114 | * |
||
115 | * @param LaravelApplication|LumenApplication $app The current application |
||
|
|||
116 | * instance that provides context and services needed to load the |
||
117 | * appropriate configuration. |
||
118 | */ |
||
119 | public function __construct(Container $app) |
||
129 | |||
130 | /** |
||
131 | * Create an instance of the loader and load the configuration in one step. |
||
132 | * |
||
133 | * @param LaravelApplication|LumenApplication $app The current application |
||
134 | * instance that provides context and services needed to load the |
||
135 | * appropriate configuration. |
||
136 | * |
||
137 | * @return self An initialized instance of this class |
||
138 | */ |
||
139 | public static function load(Container $app) |
||
146 | |||
147 | /** |
||
148 | * Load the package configuration. |
||
149 | * |
||
150 | * @return void |
||
151 | */ |
||
152 | public function loadConfiguration() |
||
164 | |||
165 | /** |
||
166 | * Determine whether the package should override Laravel's standard Redis |
||
167 | * API ("Redis" facade and "redis" service binding). |
||
168 | * |
||
169 | * @return bool TRUE if the package should override Laravel's standard |
||
170 | * Redis API |
||
171 | */ |
||
172 | public function shouldOverrideLaravelRedisApi() |
||
176 | |||
177 | /** |
||
178 | * Determine if the package should automatically configure itself. |
||
179 | * |
||
180 | * Developers may set the value of "redis-sentinel.load_config" to FALSE to |
||
181 | * disable the package's automatic configuration. This class also sets this |
||
182 | * value to FALSE after loading the package configuration to skip the auto- |
||
183 | * configuration when the application cached its configuration values (via |
||
184 | * "artisan config:cache", for example). |
||
185 | * |
||
186 | * @return bool TRUE if the package should load its configuration |
||
187 | */ |
||
188 | protected function shouldLoadConfiguration() |
||
196 | |||
197 | /** |
||
198 | * Configure the Lumen components that this package depends on. |
||
199 | * |
||
200 | * Lumen lazily loads many of its components. We must instruct Lumen to |
||
201 | * load the configuration for components that this class configures so |
||
202 | * that the values are accessible and so that the framework does not |
||
203 | * revert the configuration settings that this class changes when one of |
||
204 | * the components initializes later. |
||
205 | * |
||
206 | * @return void |
||
207 | */ |
||
208 | protected function configureLumenComponents() |
||
214 | |||
215 | /** |
||
216 | * Reconcile the package configuration and use it to set the appropriate |
||
217 | * configuration values for other application components. |
||
218 | * |
||
219 | * @return void |
||
220 | */ |
||
221 | protected function loadPackageConfiguration() |
||
235 | |||
236 | /** |
||
237 | * Set the application configuration value for the specified key with the |
||
238 | * value from the package configuration. |
||
239 | * |
||
240 | * @param string $configKey The key of the config value to set. Should |
||
241 | * correspond to a key in the package's configuration. |
||
242 | * @param bool $checkExists If TRUE, don't set the value if the key |
||
243 | * already exists in the application configuration. |
||
244 | * |
||
245 | * @return void |
||
246 | */ |
||
247 | protected function setConfigurationFor($configKey, $checkExists = true) |
||
257 | |||
258 | /** |
||
259 | * Set the application session configuration as specified by the package's |
||
260 | * configuration if the app supports sessions. |
||
261 | * |
||
262 | * @return void |
||
263 | */ |
||
264 | protected function setSessionConfiguration() |
||
275 | |||
276 | /** |
||
277 | * Get the package configuration for the specified key. |
||
278 | * |
||
279 | * @param string $configKey The key of the configuration value to get |
||
280 | * |
||
281 | * @return mixed The value of the configuration with the specified key |
||
282 | */ |
||
283 | protected function getPackageConfigurationFor($configKey) |
||
291 | |||
292 | /** |
||
293 | * Merge the package's default configuration with the override config file |
||
294 | * supplied by the developer, if any. |
||
295 | * |
||
296 | * @return void |
||
297 | */ |
||
298 | protected function mergePackageConfiguration() |
||
305 | |||
306 | /** |
||
307 | * Parse Redis Sentinel connection host definitions to create single host |
||
308 | * entries for host definitions that specify multiple hosts. |
||
309 | * |
||
310 | * @return void |
||
311 | */ |
||
312 | protected function normalizeHosts() |
||
325 | |||
326 | /** |
||
327 | * Remove the package's configuration from the application configuration |
||
328 | * repository. |
||
329 | * |
||
330 | * This package's configuration contains partial elements from several |
||
331 | * other component configurations. By default, the package removes its |
||
332 | * configuration after merging the values into each of the appropriate |
||
333 | * config locations for the components it initializes. This behavior |
||
334 | * prevents the artisan "config:cache" command from saving unnecessary |
||
335 | * configuration values to the cache file. |
||
336 | * |
||
337 | * @return void |
||
338 | */ |
||
339 | protected function cleanPackageConfiguration() |
||
350 | } |
||
351 |
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.