From 995c65cae71af8e3192f1ed62625f621fc91c176 Mon Sep 17 00:00:00 2001 From: Matias Melograno Date: Mon, 28 Mar 2022 16:17:49 -0300 Subject: [PATCH] replaced count(x) == 0 to empty --- CHANGES.txt | 4 ++-- src/SplitIO/Component/Cache/SplitCache.php | 3 +-- .../Cache/Storage/Adapter/CacheStorageAdapterInterface.php | 3 --- src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php | 6 +++--- src/SplitIO/Grammar/Condition/Matcher/PartOfSet.php | 2 +- src/SplitIO/Sdk/Validator/InputValidator.php | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 80d47dcb..83b91d3a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,8 +2,8 @@ - Removed unused logic for HTTP and requests dependency. - Removed all producer logic for Storages. - Added SafeRedisWrapper for handling exception in Redis. - - Fixed typos in bucket and CONTRIBUTORS-GUIDE. - - Added `.gitattributes` for excluding tests/. + - Added `.gitattributes` for excluding `tests/.` and other files for composer package. + - Fixed typos in `Splitter.php` and CONTRIBUTORS-GUIDE. 7.1.0 (Dec 3, 2021) - Added a new option to use when running Redis in cluster mode called `keyHashTags` which receives a list of hashtags from which the SDK will randomly pick one to use on the generated instance. diff --git a/src/SplitIO/Component/Cache/SplitCache.php b/src/SplitIO/Component/Cache/SplitCache.php index dd7bac55..dadbc767 100644 --- a/src/SplitIO/Component/Cache/SplitCache.php +++ b/src/SplitIO/Component/Cache/SplitCache.php @@ -49,8 +49,7 @@ public function getChangeNumber() public function getSplit($splitName) { $cache = Di::getCache(); - $cacheItem = $cache->get(self::getCacheKeyForSplit($splitName)); - return $cacheItem; + return $cache->get(self::getCacheKeyForSplit($splitName)); } /** diff --git a/src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php b/src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php index c193e191..fbbfb44d 100644 --- a/src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php +++ b/src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php @@ -3,9 +3,6 @@ interface CacheStorageAdapterInterface { - - // public function __construct(array $options); - /** * @param null|string $pattern * @return mixed diff --git a/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php b/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php index baa48086..9e941c3e 100644 --- a/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php +++ b/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php @@ -40,7 +40,7 @@ private function isValidConfigArray($nodes, $type) if (!is_array($nodes)) { return $type . "s must be an array."; } - if (count($nodes) == 0) { + if (empty($nodes)) { return "At least one " . $type . " is required."; } if (SplitIOUtils\isAssociativeArray($nodes)) { @@ -119,7 +119,7 @@ function ($value) { return $this->validateKeyHashTag($value)['valid']; } ); - if (count($filteredArray) == 0) { + if (empty($filteredArray)) { throw new AdapterException('keyHashTags size is zero after filtering valid elements.'); } return $selected = $filteredArray[array_rand($filteredArray, 1)]; @@ -228,7 +228,7 @@ public function get($key) public function fetchMany(array $keys = array()) { $toReturn = array(); - if (count($keys) == 0) { + if (empty($keys)) { return $toReturn; } $values = $this->client->mget($keys); diff --git a/src/SplitIO/Grammar/Condition/Matcher/PartOfSet.php b/src/SplitIO/Grammar/Condition/Matcher/PartOfSet.php index 8afb0d02..d33a6413 100644 --- a/src/SplitIO/Grammar/Condition/Matcher/PartOfSet.php +++ b/src/SplitIO/Grammar/Condition/Matcher/PartOfSet.php @@ -18,7 +18,7 @@ public function __construct($data, $negate = false, $attribute = null) protected function evalKey($key) { - if (!is_array($key) || count($key) == 0) { + if (!is_array($key) || empty($key)) { return false; } diff --git a/src/SplitIO/Sdk/Validator/InputValidator.php b/src/SplitIO/Sdk/Validator/InputValidator.php index 1f510dcc..6cdbf962 100644 --- a/src/SplitIO/Sdk/Validator/InputValidator.php +++ b/src/SplitIO/Sdk/Validator/InputValidator.php @@ -258,7 +258,7 @@ function ($featureName) use ($operation) { ) ) ); - if (count($filteredArray) == 0) { + if (empty($filteredArray)) { SplitApp::logger()->critical($operation . ': featureNames must be a non-empty array.'); return null; }