@@ -23,7 +23,7 @@ protected function tearDown(): void
2323 /**
2424 * test connection to redis and selection of db
2525 */
26- public function testConnect ()
26+ public function testConnect (): void
2727 {
2828 $ db = $ this ->getConnection (false );
2929 $ database = $ db ->database ;
@@ -48,7 +48,7 @@ public function testConnect()
4848 /**
4949 * tests whether close cleans up correctly so that a new connect works
5050 */
51- public function testReConnect ()
51+ public function testReConnect (): void
5252 {
5353 $ db = $ this ->getConnection (false );
5454 $ db ->open ();
@@ -64,7 +64,7 @@ public function testReConnect()
6464 /**
6565 * @return array
6666 */
67- public function keyValueData ()
67+ public function keyValueData (): array
6868 {
6969 return [
7070 [123 ],
@@ -80,15 +80,15 @@ public function keyValueData()
8080 * @dataProvider keyValueData
8181 * @param mixed $data
8282 */
83- public function testStoreGet ($ data )
83+ public function testStoreGet (mixed $ data ): void
8484 {
8585 $ db = $ this ->getConnection (true );
8686
8787 $ db ->set ('hi ' , $ data );
8888 $ this ->assertEquals ($ data , $ db ->get ('hi ' ));
8989 }
9090
91- public function testSerialize ()
91+ public function testSerialize (): void
9292 {
9393 $ db = $ this ->getConnection (false );
9494 $ db ->open ();
@@ -100,7 +100,7 @@ public function testSerialize()
100100 $ this ->assertTrue ($ db2 ->ping ());
101101 }
102102
103- public function testConnectionTimeout ()
103+ public function testConnectionTimeout (): void
104104 {
105105 $ db = $ this ->getConnection (false );
106106 $ db ->configSet ('timeout ' , 1 );
@@ -124,7 +124,7 @@ public function testConnectionTimeout()
124124 $ this ->assertTrue ($ exception , 'SocketException should have been thrown. ' );
125125 }
126126
127- public function testConnectionTimeoutRetry ()
127+ public function testConnectionTimeoutRetry (): void
128128 {
129129 $ logger = new Logger ();
130130 Yii::setLogger ($ logger );
@@ -146,16 +146,16 @@ public function testConnectionTimeoutRetry()
146146
147147 $ this ->assertTrue ($ db ->ping ());
148148 $ this ->assertCount (11 , $ logger ->messages , 'log +1 ping command, and reconnection. '
149- . print_r (array_map (function ($ s ) { return (string ) $ s ; }, ArrayHelper::getColumn ($ logger ->messages , 0 )), true ));
149+ . print_r (array_map (static function ($ s ) { return (string ) $ s ; }, ArrayHelper::getColumn ($ logger ->messages , 0 )), true ));
150150 }
151151
152- public function testConnectionTimeoutRetryWithFirstFail ()
152+ public function testConnectionTimeoutRetryWithFirstFail (): void
153153 {
154154 $ logger = new Logger ();
155155 Yii::setLogger ($ logger );
156156
157157 $ databases = TestCase::getParam ('databases ' );
158- $ redis = isset ( $ databases ['redis ' ]) ? $ databases [ ' redis ' ] : [];
158+ $ redis = $ databases ['redis ' ] ?? [];
159159 $ db = new ConnectionWithErrorEmulator ($ redis );
160160 $ db ->retries = 3 ;
161161
@@ -172,13 +172,13 @@ public function testConnectionTimeoutRetryWithFirstFail()
172172
173173 $ this ->assertTrue ($ db ->ping ());
174174 $ this ->assertCount (10 , $ logger ->messages , 'log +1 ping command, and two reconnections. '
175- . print_r (array_map (function ($ s ) { return (string ) $ s ; }, ArrayHelper::getColumn ($ logger ->messages , 0 )), true ));
175+ . print_r (array_map (static function ($ s ) { return (string ) $ s ; }, ArrayHelper::getColumn ($ logger ->messages , 0 )), true ));
176176 }
177177
178178 /**
179179 * Retry connecting 2 times
180180 */
181- public function testConnectionTimeoutRetryCount ()
181+ public function testConnectionTimeoutRetryCount (): void
182182 {
183183 $ logger = new Logger ();
184184 Yii::setLogger ($ logger );
@@ -209,7 +209,7 @@ public function testConnectionTimeoutRetryCount()
209209 /**
210210 * https://github.com/yiisoft/yii2/issues/4745
211211 */
212- public function testReturnType ()
212+ public function testReturnType (): void
213213 {
214214 $ redis = $ this ->getConnection ();
215215 $ redis ->executeCommand ('SET ' , ['key1 ' , 'val1 ' ]);
@@ -232,18 +232,18 @@ public function testReturnType()
232232 }
233233 }
234234
235- public function testTwoWordCommands ()
235+ public function testTwoWordCommands (): void
236236 {
237237 $ redis = $ this ->getConnection ();
238- $ this ->assertTrue ( is_array ( $ redis ->executeCommand ('CONFIG GET ' , ['port ' ]) ));
239- $ this ->assertTrue ( is_string ( $ redis ->clientList () ));
240- $ this ->assertTrue ( is_string ( $ redis ->executeCommand ('CLIENT LIST ' ) ));
238+ $ this ->assertIsArray ( $ redis ->executeCommand ('CONFIG GET ' , ['port ' ]));
239+ $ this ->assertIsString ( $ redis ->clientList ());
240+ $ this ->assertIsString ( $ redis ->executeCommand ('CLIENT LIST ' ));
241241 }
242242
243243 /**
244244 * @return array
245245 */
246- public function zRangeByScoreData ()
246+ public function zRangeByScoreData (): array
247247 {
248248 return [
249249 [
@@ -285,17 +285,17 @@ public function zRangeByScoreData()
285285 * @param array $members
286286 * @param array $cases
287287 */
288- public function testZRangeByScore ($ members , $ cases )
288+ public function testZRangeByScore (array $ members , array $ cases ): void
289289 {
290290 $ redis = $ this ->getConnection ();
291291 $ set = 'zrangebyscore ' ;
292292 foreach ($ members as $ member ) {
293- list ( $ name , $ score) = $ member ;
293+ [ $ name , $ score] = $ member ;
294294 $ this ->assertEquals (1 , $ redis ->zadd ($ set , $ score , $ name ));
295295 }
296296
297297 foreach ($ cases as $ case ) {
298- list ( $ min , $ max , $ withScores , $ limit , $ offset , $ count , $ expectedRows) = $ case ;
298+ [ $ min , $ max , $ withScores , $ limit , $ offset , $ count , $ expectedRows] = $ case ;
299299 if ($ withScores !== null && $ limit !== null ) {
300300 $ rows = $ redis ->zrangebyscore ($ set , $ min , $ max , $ withScores , $ limit , $ offset , $ count );
301301 } elseif ($ withScores !== null ) {
@@ -316,7 +316,7 @@ public function testZRangeByScore($members, $cases)
316316 /**
317317 * @return array
318318 */
319- public function hmSetData ()
319+ public function hmSetData (): array
320320 {
321321 return [
322322 [
@@ -343,7 +343,7 @@ public function hmSetData()
343343 * @param array $params
344344 * @param array $pairs
345345 */
346- public function testHMSet ($ params , $ pairs )
346+ public function testHMSet (array $ params , array $ pairs ): void
347347 {
348348 $ redis = $ this ->getConnection ();
349349 $ set = $ params [0 ];
0 commit comments