Skip to content

replaced setMethods and doc #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/SplitIO/Component/Cache/ImpressionCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace SplitIO\Component\Cache;

use SplitIO\Component\Common\Context;
use SplitIO\Component\Cache\KeyFactory;
use SplitIO\Sdk\QueueMetadataMessage;
use SplitIO\Component\Cache\Pool;

Expand Down
4 changes: 2 additions & 2 deletions src/SplitIO/Component/Cache/SplitCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static function getSplitNameFromCacheKey($key)
}

/**
* @return long
* @return int
*/
public function getChangeNumber()
{
Expand All @@ -64,7 +64,7 @@ public function getSplit($splitName)

/**
* @param array $splitNames
* @return string JSON representation
* @return array
*/
public function getSplits($splitNames)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Component/Cache/SplitCacheInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
interface SplitCacheInterface
{
/**
* @return long
* @return int
*/
public function getChangeNumber();

Expand Down
1 change: 0 additions & 1 deletion src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace SplitIO\Component\Cache\Storage\Adapter;

use SplitIO\Component\Cache\Storage\Exception\AdapterException;
use SplitIO\Component\Cache\Item;
use SplitIO\Component\Utils as SplitIOUtils;
use SplitIO\Component\Common\Context;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?php
namespace SplitIO\Component\Cache\Storage\Adapter;

use SplitIO\Component\Cache\Storage\Exception\AdapterException;
use SplitIO\Component\Cache\Item;
use SplitIO\Component\Utils as SplitIOUtils;
use SplitIO\Component\Common\Context;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/SplitIO/Component/Common/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class Context
. "Make sure you definitely want this additional instance. We recommend keeping only one instance of "
. "the factory at all times (Singleton pattern) and reusing it throughout your application.";

private \SplitIO\Component\Log\Logger $logger;
private Logger $logger;

private array $factoryTracker = array();

private string $ipAddress = "";

/**
* @var Singleton The reference to *Singleton* instance of this class
* @var Context The reference to *Singleton* instance of this class
*/
private static $instance;

Expand Down
4 changes: 2 additions & 2 deletions src/SplitIO/Component/Initialization/LoggerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LoggerFactory
* Builds defaultLogger
*
* @param $options
* @return SplitIO\Component\Log\Handler
* @return \SplitIO\Component\Log\Handler\LogHandlerInterface
*/
private static function buildAdapter(array $options)
{
Expand All @@ -42,7 +42,7 @@ private static function buildAdapter(array $options)
* Builds logger
*
* @param $options
* @return SplitIO\Component\Log\Logger
* @return \SplitIO\Component\Log\Logger
*/
public static function setupLogger(array $options)
{
Expand Down
1 change: 0 additions & 1 deletion src/SplitIO/Component/Log/Logger.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace SplitIO\Component\Log;

use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use \SplitIO\Component\Log\Handler\LogHandlerInterface;
use SplitIO\Component\Log\Handler\VoidHandler;
Expand Down
1 change: 0 additions & 1 deletion src/SplitIO/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace SplitIO;

use SplitIO\Grammar\Split as SplitGrammar;
use SplitIO\Grammar\Condition;
use SplitIO\Engine\Splitter;
use SplitIO\Grammar\Condition\ConditionTypeEnum;
use SplitIO\Sdk\Impressions\ImpressionLabel;
Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Engine/Hash/HashFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class HashFactory
{
/**
* @param $algo
* @return \SplitIO\Engine\HashInterface
* @return \SplitIO\Engine\Hash\HashInterface
*/
public static function getHashAlgorithm($algo)
{
Expand Down
8 changes: 4 additions & 4 deletions src/SplitIO/Engine/Splitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
class Splitter
{
/**
* @param HashAlgorithmEnum $algo
* @param \SplitIO\Engine\Hash\HashAlgorithmEnum $algo
* @param string $key
* @param long $seed
* @param int $seed
* @return int
*/
public static function getBucket($algo, $key, $seed)
Expand All @@ -23,9 +23,9 @@ public static function getBucket($algo, $key, $seed)

/**
* @param string $key
* @param long $seed
* @param int $seed
* @param array $partitions
* @param HashAlgorithmEnum $algo
* @param \SplitIO\Engine\Hash\HashAlgorithmEnum $algo
* @return null|string
*/
public static function getTreatment($key, $seed, $partitions, $algo)
Expand Down
1 change: 0 additions & 1 deletion src/SplitIO/Grammar/Condition/Matcher/Dependency.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace SplitIO\Grammar\Condition\Matcher;

use SplitIO\Grammar\Condition\Matcher;
use SplitIO\Sdk\Key;
use SplitIO\Exception\Exception;

class Dependency
Expand Down
1 change: 0 additions & 1 deletion src/SplitIO/Grammar/Condition/Matcher/Segment.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace SplitIO\Grammar\Condition\Matcher;

use SplitIO\Component\Cache\SegmentCache;
use SplitIO\Engine\Hash\Murmur3Hash;
use SplitIO\Grammar\Condition\Matcher;
use SplitIO\Exception\Exception;
Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Grammar/Split.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function getTreatments()
}

/**
* @return HashAlgorithmEnum
* @return \SplitIO\Engine\Hash\HashAlgorithmEnum
*/
public function getAlgo()
{
Expand Down
5 changes: 1 addition & 4 deletions src/SplitIO/Sdk.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<?php
namespace SplitIO;

use SplitIO\Component\Initialization\CacheTrait;
use SplitIO\Component\Initialization\LoggerFactory;
use SplitIO\Component\Common\ServiceProvider;
use SplitIO\Exception\Exception;
use SplitIO\Sdk\Factory\LocalhostSplitFactory;
use SplitIO\Sdk\Factory\SplitFactory;
use SplitIO\Component\Common\Context;
use SplitIO\Engine\Splitter;
use SplitIO\Component\Cache\Pool;

class Sdk
Expand Down Expand Up @@ -88,6 +85,6 @@ private static function configureCache(array $options)

private static function setIP($ip)
{
\SplitIO\Component\Common\Context::setIPAddress($ip);
Context::setIPAddress($ip);
}
}
3 changes: 0 additions & 3 deletions src/SplitIO/Sdk/Factory/SplitFactory.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?php
namespace SplitIO\Sdk\Factory;

use SplitIO\Component\Stats\Latency;
use SplitIO\Exception\TimeOutException;
use SplitIO\Sdk\Client;
use SplitIO\Sdk\LocalhostClient;
use SplitIO\Sdk\Manager\SplitManager;
use SplitIO\Component\Cache\Pool;
use SplitIO\Component\Cache\EventsCache;
Expand Down
5 changes: 5 additions & 0 deletions src/SplitIO/Sdk/Manager/LocalhostSplitManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public function splits()
return $_splits;
}

/**
* Return split
* @param mixed $featureName
* @return SplitView|null
*/
public function split($featureName)
{
$featureName = InputValidator::validateFeatureName($featureName, 'split');
Expand Down
3 changes: 1 addition & 2 deletions src/SplitIO/Sdk/Manager/SplitManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace SplitIO\Sdk\Manager;

use \stdClass;
use SplitIO\Grammar\Condition;
use SplitIO\Grammar\Split;
use SplitIO\Split as SplitApp;
use SplitIO\Component\Cache\SplitCache;
Expand Down Expand Up @@ -57,7 +56,7 @@ public function split($featureName)

/**
* @param $splitRepresentation
* @return SplitView
* @return null|SplitView
*/
private static function parseSplitView($splitRepresentation)
{
Expand Down
2 changes: 0 additions & 2 deletions src/SplitIO/Sdk/Validator/InputValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use SplitIO\Split as SplitApp;
use SplitIO\Sdk\Key;
use SplitIO\Component\Utils as SplitIOUtils;
use SplitIO\Component\Cache\SplitCache;
use SplitIO\Grammar\Condition\Partition\TreatmentEnum;
use SplitIO\Sdk\Impressions\ImpressionLabel;

const MAX_LENGTH = 250;
Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Split.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Split
{

/**
* @return null|\Psr\Log\LoggerInterface
* @return \Splitio\Component\Log\Logger
*/
public static function logger()
{
Expand Down
2 changes: 0 additions & 2 deletions src/SplitIO/functions.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
namespace SplitIO;

use SplitIO\Grammar\Condition\Partition\TreatmentEnum;

function version()
{
return Version::CURRENT;
Expand Down
7 changes: 2 additions & 5 deletions tests/Suite/Adapter/RedisAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
namespace SplitIO\Test\Suite\Adapter;

use SplitIO\Component\Cache\Storage\Adapter\PRedis;
use SplitIO\Component\Cache\Storage\Exception\AdapterException;
use \Predis\Response\ServerException;
use \Predis\ClientException;
use SplitIO\Test\Suite\Redis\ReflectiveTools;

class RedisAdapterTest extends \PHPUnit\Framework\TestCase
Expand All @@ -16,8 +13,8 @@ private function getMockedLogger()
$logger = $this
->getMockBuilder('\SplitIO\Component\Log\Logger')
->disableOriginalConstructor()
->setMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'write', 'log'))
->onlyMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'log'))
->getMock();

ReflectiveTools::overrideLogger($logger);
Expand Down
5 changes: 0 additions & 5 deletions tests/Suite/Attributes/SdkAttributesTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?php
namespace SplitIO\Test\Suite\Engine;

use Monolog\Logger;
use Monolog\Handler\ErrorLogHandler;
use SplitIO\Component\Cache\SegmentCache;
use SplitIO\Component\Cache\SplitCache;

use SplitIO\Test\Utils;

class SdkAttributesTest extends \PHPUnit\Framework\TestCase
Expand Down
3 changes: 0 additions & 3 deletions tests/Suite/Component/KeysStaticMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

namespace SplitIO\Test\Suite\Component;

use SplitIO\Component\Cache\ImpressionCache;
use SplitIO\Component\Cache\SplitCache;
use SplitIO\Component\Cache\SegmentCache;
use SplitIO\Component\Cache\TrafficTypeCache;

class KeyTest extends \PHPUnit\Framework\TestCase
{
Expand Down
7 changes: 4 additions & 3 deletions tests/Suite/Component/TrafficTypeTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private function getMockedLogger()
$logger = $this
->getMockBuilder('\SplitIO\Component\Log\Logger')
->disableOriginalConstructor()
->setMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
->onlyMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'write', 'log'))
->getMock();

Expand Down Expand Up @@ -42,10 +42,11 @@ public function testTrafficTypeWarning()

$this->assertEquals($keyTrafficType, 'SPLITIO.trafficType.abc');

$redisClient = ReflectiveTools::clientFromCachePool(Context::getCache());
$redisClient = ReflectiveTools::clientFromFactory($splitFactory);
$cachePool = ReflectiveTools::cacheFromFactory($splitFactory);
$redisClient->del($keyTrafficType);

$splitCache = new SplitCache();
$splitCache = new SplitCache($cachePool);

$this->assertEquals($splitCache->trafficTypeExists("abc"), false);

Expand Down
1 change: 0 additions & 1 deletion tests/Suite/DynamicConfigurations/EvaluatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use SplitIO\Test\Suite\Redis\ReflectiveTools;
use SplitIO\Component\Cache\SplitCache;
use SplitIO\Component\Cache\SegmentCache;
use SplitIO\Grammar\Split;
use SplitIO\Sdk\Evaluator;

class EvaluatorTest extends \PHPUnit\Framework\TestCase
Expand Down
4 changes: 0 additions & 4 deletions tests/Suite/Engine/SplitterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
namespace SplitIO\Test\Suite\Engine;

use SplitIO\Component\Initialization\LoggerFactory;
use SplitIO\Component\Common\ServiceProvider;
use SplitIO\Component\Log\LogLevelEnum;
use SplitIO\Engine\Splitter;
use SplitIO\Grammar\Condition\Partition;
use SplitIO\Engine\Hash\HashAlgorithmEnum;
use SplitIO\Grammar\Split;
use SplitIO\Engine;
use SplitIO\Component\Common\Context;

class SplitterTest extends \PHPUnit\Framework\TestCase
Expand Down
4 changes: 2 additions & 2 deletions tests/Suite/InputValidation/FactoryTrackerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ private function getMockedLogger()
$logger = $this
->getMockBuilder('\SplitIO\Component\Log\Logger')
->disableOriginalConstructor()
->setMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'write', 'log'))
->onlyMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'log'))
->getMock();

ReflectiveTools::overrideLogger($logger);
Expand Down
4 changes: 2 additions & 2 deletions tests/Suite/InputValidation/GetTreatmentValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ private function getMockedLogger()
$logger = $this
->getMockBuilder('\SplitIO\Component\Log\Logger')
->disableOriginalConstructor()
->setMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'write', 'log'))
->onlyMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'log'))
->getMock();

ReflectiveTools::overrideLogger($logger);
Expand Down
4 changes: 2 additions & 2 deletions tests/Suite/InputValidation/GetTreatmentsValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ private function getMockedLogger()
$logger = $this
->getMockBuilder('\SplitIO\Component\Log\Logger')
->disableOriginalConstructor()
->setMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'write', 'log'))
->onlyMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'log'))
->getMock();

ReflectiveTools::overrideLogger($logger);
Expand Down
4 changes: 2 additions & 2 deletions tests/Suite/InputValidation/ManagerValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ private function getMockedLogger()
$logger = $this
->getMockBuilder('\SplitIO\Component\Log\Logger')
->disableOriginalConstructor()
->setMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'write', 'log'))
->onlyMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'log'))
->getMock();

ReflectiveTools::overrideLogger($logger);
Expand Down
4 changes: 2 additions & 2 deletions tests/Suite/InputValidation/TrackValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ private function getMockedLogger()
$logger = $this
->getMockBuilder('\SplitIO\Component\Log\Logger')
->disableOriginalConstructor()
->setMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'write', 'log'))
->onlyMethods(array('warning', 'debug', 'error', 'info', 'critical', 'emergency',
'alert', 'notice', 'log'))
->getMock();

ReflectiveTools::overrideLogger($logger);
Expand Down
Loading