Skip to content

Commit 566623d

Browse files
authored
Merge pull request #185 from splitio/develop
PHP 7.1.2
2 parents e04ec97 + 458770b commit 566623d

File tree

7 files changed

+36
-8
lines changed

7 files changed

+36
-8
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
7.1.2 (May 24, 2022)
2+
- Updated validations to comply with PHP8's stricter type validations.
3+
14
7.1.1 (March 28, 2022)
25
- Removed unused logic for HTTP and requests dependency.
36
- Removed all producer logic for Storages.

src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function getKeys($pattern = '*')
279279

280280
private static function normalizePrefix($prefix)
281281
{
282-
if ($prefix && strlen($prefix)) {
282+
if ($prefix && is_string($prefix) && strlen($prefix)) {
283283
if ($prefix[strlen($prefix) - 1] == '.') {
284284
return $prefix;
285285
} else {

src/SplitIO/Grammar/Condition/Matcher/ContainsString.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public function __construct($data, $negate = false, $attribute = null)
1717

1818
protected function evalKey($key)
1919
{
20-
$keyLength = strlen($key);
21-
if (!is_array($this->containsStringMatcherData) || !is_string($key) || $keyLength == 0) {
20+
if (!is_array($this->containsStringMatcherData) || !is_string($key) || strlen($key) == 0) {
2221
return false;
2322
}
2423

src/SplitIO/Grammar/Condition/Matcher/EndsWith.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ public function __construct($data, $negate = false, $attribute = null)
1717

1818
protected function evalKey($key)
1919
{
20-
$keyLength = strlen($key);
21-
if (!is_array($this->endsWithMatcherData) || !is_string($key) || $keyLength == 0) {
20+
if (!is_array($this->endsWithMatcherData) || !is_string($key) || strlen($key) == 0) {
2221
return false;
2322
}
2423

2524
foreach ($this->endsWithMatcherData as $item) {
26-
$itemLength = strlen($item);
27-
if (is_string($item) && substr($key, -$itemLength) == $item) {
25+
if (is_string($item) && substr($key, -strlen($item)) == $item) {
2826
return true;
2927
}
3028
}

src/SplitIO/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
class Version
55
{
6-
const CURRENT = '7.1.1';
6+
const CURRENT = '7.1.2';
77
}

tests/Suite/Adapter/RedisAdapterTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,4 +514,30 @@ public function testRedisSSLWithSentinelFails()
514514
),
515515
));
516516
}
517+
518+
public function testRedisWithWrongPrefix()
519+
{
520+
$predis = new PRedis(array(
521+
'parameters' => array(
522+
'scheme' => 'tcp',
523+
'host' => 'localhost',
524+
'port' => 6379,
525+
'timeout' => 881,
526+
'database' => 0
527+
),
528+
'options' => array(
529+
'prefix' => array()
530+
)
531+
));
532+
$predisClient = new \Predis\Client([
533+
'host' => REDIS_HOST,
534+
'port' => REDIS_PORT,
535+
]);
536+
$predisClient->set('{SPLITIO}.this_is_a_test_key', 'this-is-a-test-value');
537+
538+
$value = $predis->get('{SPLITIO}.this_is_a_test_key');
539+
$this->assertEquals('this-is-a-test-value', $value);
540+
541+
$predisClient->del('{SPLITIO}.this_is_a_test_key');
542+
}
517543
}

tests/Suite/Matchers/MatchersTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public function testEndsWithMatcher()
9494
$this->assertEquals($matcher->evaluate('testJKL'), false);
9595
$this->assertEquals($matcher->evaluate(''), false);
9696
$this->assertEquals($matcher->evaluate(null), false);
97+
$this->assertEquals($matcher->evaluate(array("some")), false);
9798
}
9899

99100
public function testContainsStringMatcher()
@@ -118,6 +119,7 @@ public function testContainsStringMatcher()
118119
$this->assertEquals($matcher->evaluate('Curabitur'), false);
119120
$this->assertEquals($matcher->evaluate(''), false);
120121
$this->assertEquals($matcher->evaluate(null), false);
122+
$this->assertEquals($matcher->evaluate(array("some")), false);
121123
}
122124

123125

0 commit comments

Comments
 (0)