File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -96,9 +96,23 @@ public function createClient(string $uri): PromiseInterface
9696 // use `?password=secret` query or `user:secret@host` password form URL
9797 if (isset ($ args ['password ' ]) || isset ($ parts ['pass ' ])) {
9898 $ pass = $ args ['password ' ] ?? rawurldecode ($ parts ['pass ' ]); // @phpstan-ignore-line
99+
100+ $ user = null ;
101+ if (isset ($ args ['username ' ]) || isset ($ parts ['user ' ])) {
102+ $ user = $ args ['username ' ] ?? rawurldecode ($ parts ['user ' ]); // @phpstan-ignore-line
103+ }
104+
99105 \assert (\is_string ($ pass ));
100- $ promise = $ promise ->then (function (StreamingClient $ redis ) use ($ pass , $ uri ) {
101- return $ redis ->callAsync ('auth ' , $ pass )->then (
106+ \assert ($ user === null || \is_string ($ user ));
107+
108+ $ promise = $ promise ->then (function (StreamingClient $ redis ) use ($ user , $ pass , $ uri ) {
109+ if ($ user !== null ) {
110+ $ authPromise = $ redis ->callAsync ('auth ' , $ user , $ pass );
111+ } else {
112+ $ authPromise = $ redis ->callAsync ('auth ' , $ pass );
113+ }
114+
115+ return $ authPromise ->then (
102116 function () use ($ redis ) {
103117 return $ redis ;
104118 },
@@ -211,4 +225,4 @@ function (\Throwable $e) use ($redis, $uri) {
211225 // variable assignment needed for legacy PHPStan on PHP 7.1 only
212226 return $ ret ;
213227 }
214- }
228+ }
You can’t perform that action at this time.
0 commit comments