1 | <?php |
||
26 | class RedisSentinelServiceProvider 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 | * Boot the service by registering extensions with Laravel's cache, queue, |
||
37 | * and session managers for the "redis-sentinel" driver. |
||
38 | * |
||
39 | * @return void |
||
40 | */ |
||
41 | public function boot() |
||
42 | { |
||
43 | $this->bootComponentDrivers(); |
||
44 | |||
45 | // If we want Laravel's Redis API to use Sentinel, we'll remove the |
||
46 | // "redis" service from the deferred services in the container: |
||
47 | if ($this->config->shouldOverrideLaravelRedisApi()) { |
||
48 | $this->removeDeferredRedisServices(); |
||
49 | } |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Bind the "redis-sentinel" database driver to the application service |
||
54 | * container. |
||
55 | * |
||
56 | * @return void |
||
57 | */ |
||
58 | public function register() |
||
59 | { |
||
60 | $this->config = ConfigurationLoader::load($this->app); |
||
|
|||
61 | |||
62 | $this->app->singleton('redis-sentinel', function ($app) { |
||
63 | $class = $this->getVersionedRedisSentinelManagerClass(); |
||
64 | $config = $app->make('config')->get('database.redis-sentinel', [ ]); |
||
65 | $driver = Arr::pull($config, 'client', 'predis'); |
||
66 | |||
67 | return new RedisSentinelManager(new $class($driver, $config)); |
||
68 | }); |
||
69 | |||
70 | // If we want Laravel's Redis API to use Sentinel, we'll return an |
||
71 | // instance of the RedisSentinelManager when requesting the "redis" |
||
72 | // service: |
||
73 | if ($this->config->shouldOverrideLaravelRedisApi()) { |
||
74 | $this->registerOverrides(); |
||
75 | } |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Replace the standard Laravel Redis service with the Redis Sentinel |
||
80 | * database driver so all Redis operations use Sentinel connections. |
||
81 | * |
||
82 | * @return void |
||
83 | */ |
||
84 | protected function registerOverrides() |
||
94 | |||
95 | /** |
||
96 | * Extend each of the Laravel services this package supports with the |
||
97 | * corresponding 'redis-sentinel' driver. |
||
98 | * |
||
99 | * @return void |
||
100 | */ |
||
101 | protected function bootComponentDrivers() |
||
113 | |||
114 | /** |
||
115 | * Remove the standard Laravel Redis service from the bound deferred |
||
116 | * services so they don't overwrite Redis Sentinel registrations. |
||
117 | * |
||
118 | * @return void |
||
119 | */ |
||
120 | protected function removeDeferredRedisServices() |
||
133 | |||
134 | /** |
||
135 | * Add "redis-sentinel" as an available broadcaster option to the Laravel |
||
136 | * event broadcasting manager. |
||
137 | * |
||
138 | * @return void |
||
139 | */ |
||
140 | protected function addRedisSentinelBroadcaster() |
||
150 | |||
151 | /** |
||
152 | * Add "redis-sentinel" as an available cache store option to the Laravel |
||
153 | * cache manager. |
||
154 | * |
||
155 | * @return void |
||
156 | */ |
||
157 | protected function addRedisSentinelCacheStore() |
||
170 | |||
171 | /** |
||
172 | * Add "redis-sentinel" as an available driver option to the Laravel |
||
173 | * session manager. |
||
174 | * |
||
175 | * @return void |
||
176 | */ |
||
177 | protected function addRedisSentinelSessionHandler() |
||
190 | |||
191 | /** |
||
192 | * Add "redis-sentinel" as an available queue connection driver option to |
||
193 | * the Laravel queue manager. |
||
194 | * |
||
195 | * @return void |
||
196 | */ |
||
197 | protected function addRedisSentinelQueueConnector() |
||
205 | |||
206 | /** |
||
207 | * Get the fully-qualified class name of the RedisSentinelManager class |
||
208 | * for the current version of Laravel or Lumen. |
||
209 | * |
||
210 | * @return string The class name of the appropriate RedisSentinelManager |
||
211 | * with its namespace |
||
212 | */ |
||
213 | protected function getVersionedRedisSentinelManagerClass() |
||
229 | } |
||
230 |
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: