diff --git a/CHANGES.txt b/CHANGES.txt index 83b91d3a..ddcd9237 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ +7.1.2 (May 24, 2022) + - Updated validations to comply with PHP8's stricter type validations. + 7.1.1 (March 28, 2022) - Removed unused logic for HTTP and requests dependency. - Removed all producer logic for Storages. diff --git a/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php b/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php index 9e941c3e..d4758a47 100644 --- a/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php +++ b/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php @@ -279,7 +279,7 @@ public function getKeys($pattern = '*') private static function normalizePrefix($prefix) { - if ($prefix && strlen($prefix)) { + if ($prefix && is_string($prefix) && strlen($prefix)) { if ($prefix[strlen($prefix) - 1] == '.') { return $prefix; } else { diff --git a/src/SplitIO/Grammar/Condition/Matcher/ContainsString.php b/src/SplitIO/Grammar/Condition/Matcher/ContainsString.php index 5eb5690f..581856d9 100644 --- a/src/SplitIO/Grammar/Condition/Matcher/ContainsString.php +++ b/src/SplitIO/Grammar/Condition/Matcher/ContainsString.php @@ -17,8 +17,7 @@ public function __construct($data, $negate = false, $attribute = null) protected function evalKey($key) { - $keyLength = strlen($key); - if (!is_array($this->containsStringMatcherData) || !is_string($key) || $keyLength == 0) { + if (!is_array($this->containsStringMatcherData) || !is_string($key) || strlen($key) == 0) { return false; } diff --git a/src/SplitIO/Grammar/Condition/Matcher/EndsWith.php b/src/SplitIO/Grammar/Condition/Matcher/EndsWith.php index eb3b6db6..97f0f458 100644 --- a/src/SplitIO/Grammar/Condition/Matcher/EndsWith.php +++ b/src/SplitIO/Grammar/Condition/Matcher/EndsWith.php @@ -17,14 +17,12 @@ public function __construct($data, $negate = false, $attribute = null) protected function evalKey($key) { - $keyLength = strlen($key); - if (!is_array($this->endsWithMatcherData) || !is_string($key) || $keyLength == 0) { + if (!is_array($this->endsWithMatcherData) || !is_string($key) || strlen($key) == 0) { return false; } foreach ($this->endsWithMatcherData as $item) { - $itemLength = strlen($item); - if (is_string($item) && substr($key, -$itemLength) == $item) { + if (is_string($item) && substr($key, -strlen($item)) == $item) { return true; } } diff --git a/src/SplitIO/Version.php b/src/SplitIO/Version.php index c51d3d28..6c1aacc4 100644 --- a/src/SplitIO/Version.php +++ b/src/SplitIO/Version.php @@ -3,5 +3,5 @@ class Version { - const CURRENT = '7.1.1'; + const CURRENT = '7.1.2'; } diff --git a/tests/Suite/Adapter/RedisAdapterTest.php b/tests/Suite/Adapter/RedisAdapterTest.php index 4b14d2be..dac74c26 100644 --- a/tests/Suite/Adapter/RedisAdapterTest.php +++ b/tests/Suite/Adapter/RedisAdapterTest.php @@ -514,4 +514,30 @@ public function testRedisSSLWithSentinelFails() ), )); } + + public function testRedisWithWrongPrefix() + { + $predis = new PRedis(array( + 'parameters' => array( + 'scheme' => 'tcp', + 'host' => 'localhost', + 'port' => 6379, + 'timeout' => 881, + 'database' => 0 + ), + 'options' => array( + 'prefix' => array() + ) + )); + $predisClient = new \Predis\Client([ + 'host' => REDIS_HOST, + 'port' => REDIS_PORT, + ]); + $predisClient->set('{SPLITIO}.this_is_a_test_key', 'this-is-a-test-value'); + + $value = $predis->get('{SPLITIO}.this_is_a_test_key'); + $this->assertEquals('this-is-a-test-value', $value); + + $predisClient->del('{SPLITIO}.this_is_a_test_key'); + } } diff --git a/tests/Suite/Matchers/MatchersTest.php b/tests/Suite/Matchers/MatchersTest.php index 6b85b0dc..f0a1c57a 100644 --- a/tests/Suite/Matchers/MatchersTest.php +++ b/tests/Suite/Matchers/MatchersTest.php @@ -94,6 +94,7 @@ public function testEndsWithMatcher() $this->assertEquals($matcher->evaluate('testJKL'), false); $this->assertEquals($matcher->evaluate(''), false); $this->assertEquals($matcher->evaluate(null), false); + $this->assertEquals($matcher->evaluate(array("some")), false); } public function testContainsStringMatcher() @@ -118,6 +119,7 @@ public function testContainsStringMatcher() $this->assertEquals($matcher->evaluate('Curabitur'), false); $this->assertEquals($matcher->evaluate(''), false); $this->assertEquals($matcher->evaluate(null), false); + $this->assertEquals($matcher->evaluate(array("some")), false); }