@@ -60,9 +60,9 @@ class Redis extends Module implements RequiresPackage
60
60
*
61
61
* No default value is set for the database, using this parameter.
62
62
*
63
- * @var array
63
+ * @var array>string, mixed>
64
64
*/
65
- protected $ config = [
65
+ protected array $ config = [
66
66
'host ' => '127.0.0.1 ' ,
67
67
'port ' => 6379 ,
68
68
'cleanupBefore ' => 'never '
@@ -73,7 +73,7 @@ class Redis extends Module implements RequiresPackage
73
73
*
74
74
* @var string[]
75
75
*/
76
- protected $ requiredFields = [
76
+ protected array $ requiredFields = [
77
77
'database '
78
78
];
79
79
@@ -82,6 +82,9 @@ class Redis extends Module implements RequiresPackage
82
82
*/
83
83
public ?RedisDriver $ driver = null ;
84
84
85
+ /**
86
+ * @return array<string, string>
87
+ */
85
88
public function _requires (): array
86
89
{
87
90
return [\Predis \Client::class => '"predis/predis": "^1.0" ' ];
@@ -92,7 +95,7 @@ public function _requires(): array
92
95
*
93
96
* @throws ModuleException
94
97
*/
95
- public function _initialize ()
98
+ public function _initialize (): void
96
99
{
97
100
try {
98
101
$ this ->driver = new RedisDriver ($ this ->config );
@@ -107,9 +110,9 @@ public function _initialize()
107
110
/**
108
111
* Code to run before each suite
109
112
*
110
- * @param array $settings
113
+ * @param array<string, mixed> $settings
111
114
*/
112
- public function _beforeSuite ($ settings = [])
115
+ public function _beforeSuite ($ settings = []): void
113
116
{
114
117
if ($ this ->config ['cleanupBefore ' ] === 'suite ' ) {
115
118
$ this ->cleanup ();
@@ -119,7 +122,7 @@ public function _beforeSuite($settings = [])
119
122
/**
120
123
* Code to run before each test
121
124
*/
122
- public function _before (TestInterface $ test )
125
+ public function _before (TestInterface $ test ): void
123
126
{
124
127
if ($ this ->config ['cleanupBefore ' ] === 'test ' ) {
125
128
$ this ->cleanup ();
@@ -181,11 +184,9 @@ public function cleanup(): void
181
184
*
182
185
* @param string $key The key name
183
186
*
184
- * @return array|string|null
185
- *
186
187
* @throws ModuleException if the key does not exist
187
188
*/
188
- public function grabFromRedis (string $ key )
189
+ public function grabFromRedis (string $ key ): array | string | null
189
190
{
190
191
$ args = func_get_args ();
191
192
@@ -280,7 +281,7 @@ public function grabFromRedis(string $key)
280
281
*
281
282
* @throws ModuleException
282
283
*/
283
- public function haveInRedis (string $ type , string $ key , $ value ): void
284
+ public function haveInRedis (string $ type , string $ key , mixed $ value ): void
284
285
{
285
286
switch (strtolower ($ type )) {
286
287
case 'string ' :
@@ -364,7 +365,7 @@ public function haveInRedis(string $type, string $key, $value): void
364
365
* @param mixed $value Optional. If specified, also checks the key has this
365
366
* value. Booleans will be converted to 1 and 0 (even inside arrays)
366
367
*/
367
- public function dontSeeInRedis (string $ key , $ value = null ): void
368
+ public function dontSeeInRedis (string $ key , mixed $ value = null ): void
368
369
{
369
370
try {
370
371
$ this ->assertFalse (
@@ -408,10 +409,10 @@ public function dontSeeInRedis(string $key, $value = null): void
408
409
*
409
410
* @param string $key The key
410
411
* @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
412
413
* specified, the method will also check that the $item has this value/score
413
414
*/
414
- public function dontSeeRedisKeyContains (string $ key , $ item , $ itemValue = null ): void
415
+ public function dontSeeRedisKeyContains (string $ key , mixed $ item , mixed $ itemValue = null ): void
415
416
{
416
417
$ this ->assertFalse (
417
418
$ this ->checkKeyContains ($ key , $ item , $ itemValue ),
@@ -453,7 +454,7 @@ public function dontSeeRedisKeyContains(string $key, $item, $itemValue = null):
453
454
* @param mixed $value Optional. If specified, also checks the key has this
454
455
* value. Booleans will be converted to 1 and 0 (even inside arrays)
455
456
*/
456
- public function seeInRedis (string $ key , $ value = null ): void
457
+ public function seeInRedis (string $ key , mixed $ value = null ): void
457
458
{
458
459
try {
459
460
$ this ->assertTrue (
@@ -487,7 +488,7 @@ public function seeInRedis(string $key, $value = null): void
487
488
* @param string $command The command name
488
489
* @return mixed
489
490
*/
490
- public function sendCommandToRedis (string $ command )
491
+ public function sendCommandToRedis (string $ command ): mixed
491
492
{
492
493
return call_user_func_array (
493
494
[$ this ->driver , $ command ],
@@ -526,10 +527,10 @@ public function sendCommandToRedis(string $command)
526
527
*
527
528
* @param string $key The key
528
529
* @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
530
531
* specified, the method will also check that the $item has this value/score
531
532
*/
532
- public function seeRedisKeyContains (string $ key , $ item , $ itemValue = null ): void
533
+ public function seeRedisKeyContains (string $ key , mixed $ item , mixed $ itemValue = null ): void
533
534
{
534
535
$ this ->assertTrue (
535
536
$ this ->checkKeyContains ($ key , $ item , $ itemValue ),
@@ -543,11 +544,8 @@ public function seeRedisKeyContains(string $key, $item, $itemValue = null): void
543
544
544
545
/**
545
546
* Converts boolean values to "0" and "1"
546
- *
547
- * @param mixed $var The variable
548
- * @return mixed
549
547
*/
550
- private function boolToString ($ var )
548
+ private function boolToString (mixed $ var ): mixed
551
549
{
552
550
$ copy = is_array ($ var ) ? $ var : [$ var ];
553
551
@@ -565,13 +563,12 @@ private function boolToString($var)
565
563
*
566
564
* @param string $key The key
567
565
* @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
569
567
* specified, the method will also check that the $item has this value/score
570
568
*
571
- * @return bool
572
569
* @throws ModuleException
573
570
*/
574
- private function checkKeyContains (string $ key , $ item , $ itemValue = null ): bool
571
+ private function checkKeyContains (string $ key , mixed $ item , mixed $ itemValue = null ): bool
575
572
{
576
573
$ result = null ;
577
574
@@ -635,7 +632,7 @@ private function checkKeyContains(string $key, $item, $itemValue = null): bool
635
632
* @param mixed $value Optional. If specified, also checks the key has this
636
633
* value. Booleans will be converted to 1 and 0 (even inside arrays)
637
634
*/
638
- private function checkKeyExists (string $ key , $ value ): bool
635
+ private function checkKeyExists (string $ key , mixed $ value ): bool
639
636
{
640
637
$ type = $ this ->driver ->type ($ key );
641
638
@@ -718,8 +715,6 @@ private function checkKeyExists(string $key, $value): bool
718
715
* Explicitly cast the scores of a Zset associative array as float/double
719
716
*
720
717
* @param array $arr The ZSet associative array
721
- *
722
- * @return array
723
718
*/
724
719
private function scoresToFloat (array $ arr ): array
725
720
{
0 commit comments