Skip to content

Commit a8e2716

Browse files
committed
chore: Cleanup and strict types
1 parent 08eda61 commit a8e2716

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
This library provides a Redis-backed data source for the [LaunchDarkly PHP SDK](https://github.com/launchdarkly/php-server-sdk), replacing the default behavior of querying the LaunchDarkly service endpoints. The underlying Redis client implementation is the [`phpredis`](https://github.com/phpredis/phpredis) extension. If you want to use the Predis package instead, see https://github.com/launchdarkly/php-server-sdk-redis-predis.
88

9-
The minimum version of the LaunchDarkly PHP SDK for use with this library is 4.0.0. In earlier versions of the SDK, the Redis integrations were bundled in the main SDK package.
9+
The minimum version of the LaunchDarkly PHP SDK for use with this library is 6.4.0.
1010

11-
The minimum PHP version is 7.3.
11+
The minimum PHP version is 8.1.
1212

1313
For more information, see [our SDK documentation](https://docs.launchdarkly.com/sdk/features/storing-data).
1414

@@ -27,15 +27,13 @@ php composer.phar install launchdarkly/server-sdk-redis-phpredis --save
2727
3. In your SDK configuration code, configure the Redis integration:
2828

2929
```php
30-
$fr = LaunchDarkly\Integrations\PHPRedis::featureRequester([
31-
"prefix" => "my-key-prefix"
32-
]);
33-
$config = [ "feature_requester" => $fr ];
30+
$fr = LaunchDarkly\Integrations\PHPRedis::featureRequester(
31+
$redisClient, ["prefix" => "my-key-prefix"]
32+
);
33+
$config = ["feature_requester" => $fr];
3434
$client = new LDClient("sdk_key", $config);
3535
```
3636

37-
By default, the store will try to connect to a local Redis instance on port 6379. You may specify an alternate configuration as described in the API documentation for `PHPRedis::featureRequester`. Make sure the `prefix` option corresponds to the key prefix that is being used by the Relay Proxy.
38-
3937
## About LaunchDarkly
4038

4139
* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:

src/LaunchDarkly/Impl/Integrations/PHPRedisFeatureRequester.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace LaunchDarkly\Impl\Integrations;
46

57
use LaunchDarkly\Integrations;
@@ -35,7 +37,13 @@ protected function readItemString(string $namespace, string $key): ?string
3537

3638
protected function readItemStringList(string $namespace): ?array
3739
{
40+
/** @var ?array<string, string> */
3841
$raw = $this->client->hgetall("$this->prefix:$namespace");
39-
return $raw ? array_values($raw) : null;
42+
43+
if ($raw === null) {
44+
return null;
45+
}
46+
47+
return array_values($raw);
4048
}
4149
}

src/LaunchDarkly/Integrations/PHPRedis.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace LaunchDarkly\Integrations;
46

57
use LaunchDarkly\Impl\Integrations;
@@ -21,8 +23,8 @@ class PHPRedis
2123
* To use this method, you must have installed the `phpredis` extension. After calling this
2224
* method, store its return value in the `feature_requester` property of your client configuration:
2325
*
24-
* $fr = LaunchDarkly\Integrations\PHPRedis::featureRequester([ "redis_prefix" => "env1" ]);
25-
* $config = [ "feature_requester" => $fr ];
26+
* $fr = LaunchDarkly\Integrations\PHPRedis::featureRequester(["prefix" => "env1"]);
27+
* $config = ["feature_requester" => $fr];
2628
* $client = new LDClient("sdk_key", $config);
2729
*
2830
* For more about using LaunchDarkly with databases, see the

tests/Impl/Integrations/PHPRedisBigSegmentsStoreTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace LaunchDarkly\Impl\Integrations\Tests\Impl\Integrations;
46

57
use Exception;

tests/Impl/Integrations/PHPRedisFeatureRequesterTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace LaunchDarkly\Impl\Integrations\Tests\Impl\Integrations;
46

57
use LaunchDarkly\Impl\Model\FeatureFlag;

0 commit comments

Comments
 (0)