@@ -60,9 +60,9 @@ class Redis extends Module implements RequiresPackage
6060 *
6161 * No default value is set for the database, using this parameter.
6262 *
63- * @var array
63+ * @var array>string, mixed>
6464 */
65- protected $ config = [
65+ protected array $ config = [
6666 'host ' => '127.0.0.1 ' ,
6767 'port ' => 6379 ,
6868 'cleanupBefore ' => 'never '
@@ -73,7 +73,7 @@ class Redis extends Module implements RequiresPackage
7373 *
7474 * @var string[]
7575 */
76- protected $ requiredFields = [
76+ protected array $ requiredFields = [
7777 'database '
7878 ];
7979
@@ -82,6 +82,9 @@ class Redis extends Module implements RequiresPackage
8282 */
8383 public ?RedisDriver $ driver = null ;
8484
85+ /**
86+ * @return array<string, string>
87+ */
8588 public function _requires (): array
8689 {
8790 return [\Predis \Client::class => '"predis/predis": "^1.0" ' ];
@@ -92,7 +95,7 @@ public function _requires(): array
9295 *
9396 * @throws ModuleException
9497 */
95- public function _initialize ()
98+ public function _initialize (): void
9699 {
97100 try {
98101 $ this ->driver = new RedisDriver ($ this ->config );
@@ -107,9 +110,9 @@ public function _initialize()
107110 /**
108111 * Code to run before each suite
109112 *
110- * @param array $settings
113+ * @param array<string, mixed> $settings
111114 */
112- public function _beforeSuite ($ settings = [])
115+ public function _beforeSuite ($ settings = []): void
113116 {
114117 if ($ this ->config ['cleanupBefore ' ] === 'suite ' ) {
115118 $ this ->cleanup ();
@@ -119,7 +122,7 @@ public function _beforeSuite($settings = [])
119122 /**
120123 * Code to run before each test
121124 */
122- public function _before (TestInterface $ test )
125+ public function _before (TestInterface $ test ): void
123126 {
124127 if ($ this ->config ['cleanupBefore ' ] === 'test ' ) {
125128 $ this ->cleanup ();
@@ -181,11 +184,9 @@ public function cleanup(): void
181184 *
182185 * @param string $key The key name
183186 *
184- * @return array|string|null
185- *
186187 * @throws ModuleException if the key does not exist
187188 */
188- public function grabFromRedis (string $ key )
189+ public function grabFromRedis (string $ key ): array | string | null
189190 {
190191 $ args = func_get_args ();
191192
@@ -280,7 +281,7 @@ public function grabFromRedis(string $key)
280281 *
281282 * @throws ModuleException
282283 */
283- public function haveInRedis (string $ type , string $ key , $ value ): void
284+ public function haveInRedis (string $ type , string $ key , mixed $ value ): void
284285 {
285286 switch (strtolower ($ type )) {
286287 case 'string ' :
@@ -364,7 +365,7 @@ public function haveInRedis(string $type, string $key, $value): void
364365 * @param mixed $value Optional. If specified, also checks the key has this
365366 * value. Booleans will be converted to 1 and 0 (even inside arrays)
366367 */
367- public function dontSeeInRedis (string $ key , $ value = null ): void
368+ public function dontSeeInRedis (string $ key , mixed $ value = null ): void
368369 {
369370 try {
370371 $ this ->assertFalse (
@@ -408,10 +409,10 @@ public function dontSeeInRedis(string $key, $value = null): void
408409 *
409410 * @param string $key The key
410411 * @param mixed $item The item
411- * @param null $itemValue Optional and only used for zsets and hashes. If
412+ * @param mixed $itemValue Optional and only used for zsets and hashes. If
412413 * specified, the method will also check that the $item has this value/score
413414 */
414- public function dontSeeRedisKeyContains (string $ key , $ item , $ itemValue = null ): void
415+ public function dontSeeRedisKeyContains (string $ key , mixed $ item , mixed $ itemValue = null ): void
415416 {
416417 $ this ->assertFalse (
417418 $ this ->checkKeyContains ($ key , $ item , $ itemValue ),
@@ -453,7 +454,7 @@ public function dontSeeRedisKeyContains(string $key, $item, $itemValue = null):
453454 * @param mixed $value Optional. If specified, also checks the key has this
454455 * value. Booleans will be converted to 1 and 0 (even inside arrays)
455456 */
456- public function seeInRedis (string $ key , $ value = null ): void
457+ public function seeInRedis (string $ key , mixed $ value = null ): void
457458 {
458459 try {
459460 $ this ->assertTrue (
@@ -487,7 +488,7 @@ public function seeInRedis(string $key, $value = null): void
487488 * @param string $command The command name
488489 * @return mixed
489490 */
490- public function sendCommandToRedis (string $ command )
491+ public function sendCommandToRedis (string $ command ): mixed
491492 {
492493 return call_user_func_array (
493494 [$ this ->driver , $ command ],
@@ -526,10 +527,10 @@ public function sendCommandToRedis(string $command)
526527 *
527528 * @param string $key The key
528529 * @param mixed $item The item
529- * @param null $itemValue Optional and only used for zsets and hashes. If
530+ * @param mixed $itemValue Optional and only used for zsets and hashes. If
530531 * specified, the method will also check that the $item has this value/score
531532 */
532- public function seeRedisKeyContains (string $ key , $ item , $ itemValue = null ): void
533+ public function seeRedisKeyContains (string $ key , mixed $ item , mixed $ itemValue = null ): void
533534 {
534535 $ this ->assertTrue (
535536 $ this ->checkKeyContains ($ key , $ item , $ itemValue ),
@@ -543,11 +544,8 @@ public function seeRedisKeyContains(string $key, $item, $itemValue = null): void
543544
544545 /**
545546 * Converts boolean values to "0" and "1"
546- *
547- * @param mixed $var The variable
548- * @return mixed
549547 */
550- private function boolToString ($ var )
548+ private function boolToString (mixed $ var ): mixed
551549 {
552550 $ copy = is_array ($ var ) ? $ var : [$ var ];
553551
@@ -565,13 +563,12 @@ private function boolToString($var)
565563 *
566564 * @param string $key The key
567565 * @param mixed $item The item
568- * @param null $itemValue Optional and only used for zsets and hashes. If
566+ * @param mixed $itemValue Optional and only used for zsets and hashes. If
569567 * specified, the method will also check that the $item has this value/score
570568 *
571- * @return bool
572569 * @throws ModuleException
573570 */
574- private function checkKeyContains (string $ key , $ item , $ itemValue = null ): bool
571+ private function checkKeyContains (string $ key , mixed $ item , mixed $ itemValue = null ): bool
575572 {
576573 $ result = null ;
577574
@@ -635,7 +632,7 @@ private function checkKeyContains(string $key, $item, $itemValue = null): bool
635632 * @param mixed $value Optional. If specified, also checks the key has this
636633 * value. Booleans will be converted to 1 and 0 (even inside arrays)
637634 */
638- private function checkKeyExists (string $ key , $ value ): bool
635+ private function checkKeyExists (string $ key , mixed $ value ): bool
639636 {
640637 $ type = $ this ->driver ->type ($ key );
641638
@@ -718,8 +715,6 @@ private function checkKeyExists(string $key, $value): bool
718715 * Explicitly cast the scores of a Zset associative array as float/double
719716 *
720717 * @param array $arr The ZSet associative array
721- *
722- * @return array
723718 */
724719 private function scoresToFloat (array $ arr ): array
725720 {
0 commit comments