@@ -18,19 +18,14 @@ class Factory
18
18
19
19
/**
20
20
* @param LoopInterface $loop
21
- * @param ConnectorInterface|\React\SocketClient\ConnectorInterface|null $connector
22
- * [optional] Connector to use. Should be `null` in order to use default
23
- * Connector. Passing a `\React\SocketClient\ConnectorInterface` is
24
- * deprecated and only supported for BC reasons and will be removed in
25
- * future versions.
21
+ * @param ConnectorInterface|null $connector [optional] Connector to use.
22
+ * Should be `null` in order to use default Connector.
26
23
* @param ProtocolFactory|null $protocol
27
24
*/
28
- public function __construct (LoopInterface $ loop , $ connector = null , ProtocolFactory $ protocol = null )
25
+ public function __construct (LoopInterface $ loop , ConnectorInterface $ connector = null , ProtocolFactory $ protocol = null )
29
26
{
30
27
if ($ connector === null ) {
31
28
$ connector = new Connector ($ loop );
32
- } elseif (!$ connector instanceof ConnectorInterface) {
33
- $ connector = new ConnectorUpcaster ($ connector );
34
29
}
35
30
36
31
if ($ protocol === null ) {
@@ -44,12 +39,10 @@ public function __construct(LoopInterface $loop, $connector = null, ProtocolFact
44
39
/**
45
40
* create redis client connected to address of given redis instance
46
41
*
47
- * @param string|null $target Redis server URI to connect to. Not passing
48
- * this parameter is deprecated and only supported for BC reasons and
49
- * will be removed in future versions.
42
+ * @param string $target Redis server URI to connect to
50
43
* @return \React\Promise\PromiseInterface resolves with Client or rejects with \Exception
51
44
*/
52
- public function createClient ($ target = null )
45
+ public function createClient ($ target )
53
46
{
54
47
try {
55
48
$ parts = $ this ->parseUrl ($ target );
@@ -95,21 +88,18 @@ function ($error) use ($client) {
95
88
}
96
89
97
90
/**
98
- * @param string|null $target
91
+ * @param string $target
99
92
* @return array with keys host, port, auth and db
100
93
* @throws InvalidArgumentException
101
94
*/
102
95
private function parseUrl ($ target )
103
96
{
104
- if ($ target === null ) {
105
- $ target = 'tcp://127.0.0.1 ' ;
106
- }
107
97
if (strpos ($ target , ':// ' ) === false ) {
108
- $ target = 'tcp :// ' . $ target ;
98
+ $ target = 'redis :// ' . $ target ;
109
99
}
110
100
111
101
$ parts = parse_url ($ target );
112
- if ($ parts === false || !isset ($ parts ['scheme ' ], $ parts ['host ' ]) || !in_array ($ parts ['scheme ' ], array ('tcp ' , ' redis ' , 'rediss ' ))) {
102
+ if ($ parts === false || !isset ($ parts ['scheme ' ], $ parts ['host ' ]) || !in_array ($ parts ['scheme ' ], array ('redis ' , 'rediss ' ))) {
113
103
throw new InvalidArgumentException ('Given URL can not be parsed ' );
114
104
}
115
105
@@ -121,15 +111,8 @@ private function parseUrl($target)
121
111
$ parts ['host ' ] = '127.0.0.1 ' ;
122
112
}
123
113
124
- $ auth = null ;
125
- if (isset ($ parts ['user ' ]) && $ parts ['scheme ' ] === 'tcp ' ) {
126
- $ auth = rawurldecode ($ parts ['user ' ]);
127
- }
128
114
if (isset ($ parts ['pass ' ])) {
129
- $ auth .= ($ parts ['scheme ' ] === 'tcp ' ? ': ' : '' ) . rawurldecode ($ parts ['pass ' ]);
130
- }
131
- if ($ auth !== null ) {
132
- $ parts ['auth ' ] = $ auth ;
115
+ $ parts ['auth ' ] = rawurldecode ($ parts ['pass ' ]);
133
116
}
134
117
135
118
if (isset ($ parts ['path ' ]) && $ parts ['path ' ] !== '' ) {
0 commit comments