@@ -155,18 +155,18 @@ private static function initializeRedisCluster(?\RedisCluster $redis, array $hos
155
155
public static function fromDsn (string $ dsn , array $ redisOptions = [], $ redis = null ): self
156
156
{
157
157
if (false === strpos ($ dsn , ', ' )) {
158
- $ parsedUrl = self ::parseDsn ($ dsn , $ redisOptions );
158
+ $ params = self ::parseDsn ($ dsn , $ redisOptions );
159
159
} else {
160
160
$ dsns = explode (', ' , $ dsn );
161
161
$ parsedUrls = array_map (function ($ dsn ) use (&$ redisOptions ) {
162
162
return self ::parseDsn ($ dsn , $ redisOptions );
163
163
}, $ dsns );
164
164
165
165
// Merge all the URLs, the last one overrides the previous ones
166
- $ parsedUrl = array_merge (...$ parsedUrls );
166
+ $ params = array_merge (...$ parsedUrls );
167
167
168
168
// Regroup all the hosts in an array interpretable by RedisCluster
169
- $ parsedUrl ['host ' ] = array_map (function ($ parsedUrl ) {
169
+ $ params ['host ' ] = array_map (function ($ parsedUrl ) {
170
170
if (!isset ($ parsedUrl ['host ' ])) {
171
171
throw new InvalidArgumentException ('Missing host in DSN, it must be defined when using Redis Cluster. ' );
172
172
}
@@ -209,7 +209,7 @@ public static function fromDsn(string $dsn, array $redisOptions = [], $redis = n
209
209
unset($ redisOptions ['dbindex ' ]);
210
210
}
211
211
212
- $ tls = 'rediss ' === $ parsedUrl ['scheme ' ];
212
+ $ tls = 'rediss ' === $ params ['scheme ' ];
213
213
if (\array_key_exists ('tls ' , $ redisOptions )) {
214
214
trigger_deprecation ('symfony/redis-messenger ' , '5.3 ' , 'Providing "tls" parameter is deprecated, use "rediss://" DSN scheme instead ' );
215
215
$ tls = filter_var ($ redisOptions ['tls ' ], \FILTER_VALIDATE_BOOLEAN );
@@ -242,17 +242,17 @@ public static function fromDsn(string $dsn, array $redisOptions = [], $redis = n
242
242
'claim_interval ' => $ claimInterval ,
243
243
];
244
244
245
- if (isset ($ parsedUrl ['host ' ])) {
246
- $ pass = '' !== ( $ parsedUrl [ ' pass ' ] ?? '' ) ? urldecode ( $ parsedUrl [ ' pass ' ]) : null ;
247
- $ user = '' !== ( $ parsedUrl [ ' user ' ] ?? '' ) ? urldecode ( $ parsedUrl [ ' user ' ]) : null ;
245
+ if (isset ($ params ['host ' ])) {
246
+ $ user = isset ( $ params [ ' user ' ]) && '' !== $ params [ ' user ' ] ? rawurldecode ( $ params [ ' user ' ]) : null ;
247
+ $ pass = isset ( $ params [ ' pass ' ]) && '' !== $ params [ ' pass ' ] ? rawurldecode ( $ params [ ' pass ' ]) : null ;
248
248
$ connectionCredentials = [
249
- 'host ' => $ parsedUrl ['host ' ] ?? ' 127.0.0.1 ' ,
250
- 'port ' => $ parsedUrl ['port ' ] ?? 6379 ,
249
+ 'host ' => $ params ['host ' ],
250
+ 'port ' => $ params ['port ' ] ?? 6379 ,
251
251
// See: https://github.com/phpredis/phpredis/#auth
252
252
'auth ' => $ redisOptions ['auth ' ] ?? (null !== $ pass && null !== $ user ? [$ user , $ pass ] : ($ pass ?? $ user )),
253
253
];
254
254
255
- $ pathParts = explode ('/ ' , rtrim ($ parsedUrl ['path ' ] ?? '' , '/ ' ));
255
+ $ pathParts = explode ('/ ' , rtrim ($ params ['path ' ] ?? '' , '/ ' ));
256
256
257
257
$ configuration ['stream ' ] = $ pathParts [1 ] ?? $ configuration ['stream ' ];
258
258
$ configuration ['group ' ] = $ pathParts [2 ] ?? $ configuration ['group ' ];
@@ -262,7 +262,7 @@ public static function fromDsn(string $dsn, array $redisOptions = [], $redis = n
262
262
}
263
263
} else {
264
264
$ connectionCredentials = [
265
- 'host ' => $ parsedUrl ['path ' ],
265
+ 'host ' => $ params ['path ' ],
266
266
'port ' => 0 ,
267
267
];
268
268
}
@@ -279,15 +279,15 @@ private static function parseDsn(string $dsn, array &$redisOptions): array
279
279
$ url = str_replace ($ scheme .': ' , 'file: ' , $ dsn );
280
280
}
281
281
282
- if (false === $ parsedUrl = parse_url ($ url )) {
282
+ if (false === $ params = parse_url ($ url )) {
283
283
throw new InvalidArgumentException ('The given Redis DSN is invalid. ' );
284
284
}
285
- if (isset ($ parsedUrl ['query ' ])) {
286
- parse_str ($ parsedUrl ['query ' ], $ dsnOptions );
285
+ if (isset ($ params ['query ' ])) {
286
+ parse_str ($ params ['query ' ], $ dsnOptions );
287
287
$ redisOptions = array_merge ($ redisOptions , $ dsnOptions );
288
288
}
289
289
290
- return $ parsedUrl ;
290
+ return $ params ;
291
291
}
292
292
293
293
private static function validateOptions (array $ options ): void
0 commit comments