@@ -56,15 +56,15 @@ private function http()
5656 return $ this ->http ;
5757 }
5858
59- private function buildKeyUri (string $ key ) : string
59+ private function buildKeyUri (string $ key ): string
6060 {
6161 if (strpos ($ key , '/ ' ) !== 0 ) {
6262 $ key = '/ ' . $ key ;
6363 }
6464
6565 $ root = $ this ->root ;
6666 if (strlen ($ root ) > 0 && strpos ($ root , '/ ' ) !== 0 ) {
67- $ root = '/ ' . $ root ;
67+ $ root = '/ ' . $ root ;
6868 }
6969
7070 $ uri = '/ ' . $ this ->apiversion . '/keys ' . $ root . $ key ;
@@ -83,7 +83,7 @@ private function buildKeyUri(string $key) : string
8383 * // the new key is /datingvip/key1
8484 * </code>
8585 */
86- public function setRoot (string $ root ) : ClientInterface
86+ public function setRoot (string $ root ): ClientInterface
8787 {
8888 if (strpos ('/ ' , $ root ) === false ) {
8989 $ root = '/ ' . $ root ;
@@ -93,7 +93,7 @@ public function setRoot(string $root) : ClientInterface
9393 return $ this ;
9494 }
9595
96- public function getNode (string $ key , array $ flags = null )
96+ public function getNode (string $ key , ? array $ flags = null )
9797 {
9898 $ query = [];
9999 if ($ flags ) {
@@ -115,7 +115,7 @@ public function getNode(string $key, array $flags = null)
115115 return $ response ['node ' ];
116116 }
117117
118- public function keySet (string $ key , string $ value , int $ ttl = null , array $ condition = []) : bool
118+ public function keySet (string $ key , string $ value , ? int $ ttl = null , array $ condition = []): bool
119119 {
120120 $ data = ['value ' => $ value ];
121121
@@ -131,7 +131,7 @@ public function keySet(string $key, string $value, int $ttl = null, array $condi
131131 return false ;
132132 }
133133
134- public function keyCreate (string $ key , string $ value , int $ ttl = null , array $ condition = []) : bool
134+ public function keyCreate (string $ key , string $ value , ? int $ ttl = null , array $ condition = []): bool
135135 {
136136 $ extra = ['prevExist ' => 'false ' ];
137137
@@ -142,7 +142,7 @@ public function keyCreate(string $key, string $value, int $ttl = null, array $co
142142 return $ this ->keySet ($ key , $ value , $ ttl , $ extra );
143143 }
144144
145- public function keyUpdate (string $ key , string $ value , int $ ttl = null , array $ condition = []) : bool
145+ public function keyUpdate (string $ key , string $ value , ? int $ ttl = null , array $ condition = []): bool
146146 {
147147 $ extra = ['prevExist ' => 'true ' ];
148148
@@ -153,19 +153,19 @@ public function keyUpdate(string $key, string $value, int $ttl = null, array $co
153153 return $ this ->keySet ($ key , $ value , $ ttl , $ extra );
154154 }
155155
156- public function keyGet (string $ key , array $ flags = null ) : string
156+ public function keyGet (string $ key , ? array $ flags = null ): string
157157 {
158158 $ node = $ this ->getNode ($ key , $ flags );
159159
160160 return $ node ['value ' ] ?? '' ;
161161 }
162162
163- public function keyRemove (string $ key ) : bool
163+ public function keyRemove (string $ key ): bool
164164 {
165165 return (bool ) $ this ->http ()->delete ($ this ->buildKeyUri ($ key ));
166166 }
167167
168- public function keyExists (string $ key ) : bool
168+ public function keyExists (string $ key ): bool
169169 {
170170 $ url = $ this ->buildKeyUri ($ key );
171171 $ response = json_decode ($ this ->curlExec ($ this ->curl ($ url ), $ url ), true );
@@ -177,7 +177,7 @@ public function keyExists(string $key) : bool
177177 return false ;
178178 }
179179
180- public function dirCreate (string $ key , int $ ttl = 0 ) : bool
180+ public function dirCreate (string $ key , int $ ttl = 0 ): bool
181181 {
182182 $ data = ['dir ' => 'true ' ];
183183
@@ -188,7 +188,7 @@ public function dirCreate(string $key, int $ttl = 0) : bool
188188 return (bool )$ this ->http ()->put ($ this ->buildKeyUri ($ key ), $ data , ['prevExist ' => 'false ' ]);
189189 }
190190
191- public function dirUpdate (string $ key , int $ ttl = 0 ) : bool
191+ public function dirUpdate (string $ key , int $ ttl = 0 ): bool
192192 {
193193 $ data = ['dir ' => 'true ' ];
194194
@@ -199,7 +199,7 @@ public function dirUpdate(string $key, int $ttl = 0) : bool
199199 return (bool ) $ this ->http ()->put ($ this ->buildKeyUri ($ key ), $ data , ['prevExist ' => 'true ' ]);
200200 }
201201
202- public function dirRemove (string $ key , bool $ recursive = false ) : bool
202+ public function dirRemove (string $ key , bool $ recursive = false ): bool
203203 {
204204 $ query = ['dir ' => 'true ' ];
205205
@@ -210,7 +210,7 @@ public function dirRemove(string $key, bool $recursive = false) : bool
210210 return (bool ) $ this ->http ()->delete ($ this ->buildKeyUri ($ key ), $ query );
211211 }
212212
213- public function dirExists (string $ key ) : bool
213+ public function dirExists (string $ key ): bool
214214 {
215215 $ url = $ this ->buildKeyUri ($ key );
216216 $ response = json_decode ($ this ->curlExec ($ this ->curl ($ url ), $ url ), true );
@@ -222,7 +222,7 @@ public function dirExists(string $key) : bool
222222 return false ;
223223 }
224224
225- public function dirGet (string $ key , bool $ recursive = false ) : array
225+ public function dirGet (string $ key , bool $ recursive = false ): array
226226 {
227227 $ query = [];
228228 if ($ recursive ) {
@@ -232,7 +232,7 @@ public function dirGet(string $key, bool $recursive = false) : array
232232 return $ this ->http ()->get ($ this ->buildKeyUri ($ key ), $ query );
233233 }
234234
235- public function dirList (string $ key , bool $ recursive = false ) : array
235+ public function dirList (string $ key , bool $ recursive = false ): array
236236 {
237237 try {
238238 $ data = $ this ->dirGet ($ key , $ recursive );
@@ -243,7 +243,7 @@ public function dirList(string $key, bool $recursive = false) : array
243243 return $ this ->traversalDir ((new RecursiveArrayIterator ($ data )));
244244 }
245245
246- private function traversalDir (RecursiveArrayIterator $ iterator ) : array
246+ private function traversalDir (RecursiveArrayIterator $ iterator ): array
247247 {
248248 $ key = '' ;
249249 while ($ iterator ->valid ()) {
0 commit comments