Skip to content
Open
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
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
- '8.5'
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -60,7 +62,7 @@ jobs:

- name: SonarQube Scan (Push)
if: matrix.version == '8.2' && github.event_name == 'push'
uses: SonarSource/sonarcloud-github-action@v1.9
uses: SonarSource/sonarcloud-github-action@v3
env:
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -72,7 +74,7 @@ jobs:

- name: SonarQube Scan (Pull Request)
if: matrix.version == '8.2' && github.event_name == 'pull_request'
uses: SonarSource/sonarcloud-github-action@v1.9
uses: SonarSource/sonarcloud-github-action@v3
env:
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via feature flags to manage your complete customer experience.

## Compatibility
This SDK is compatible with PHP 7.3 and above.
This SDK is compatible with PHP 7.3 and above, including PHP 8.4 and 8.5.

## Getting started
Below is a simple example that describes the instantiation and most basic usage of our SDK.
Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Component/Log/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Logger extends LoggerTrait
* Logger constructor
* @param LogHandlerInterface|null $handler
*/
public function __construct(LogHandlerInterface $handler = null, $level = LogLevel::WARNING)
public function __construct(?LogHandlerInterface $handler = null, $level = LogLevel::WARNING)
{
$this->logLevel = $this->logLevels[$level];

Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Engine
* @param array|null $attributes
* @return array
*/
public static function getTreatment($matchingKey, $bucketingKey, SplitGrammar $split, array $attributes = null)
public static function getTreatment($matchingKey, $bucketingKey, SplitGrammar $split, ?array $attributes = null)
{
if ($bucketingKey === null) {
$bucketingKey = $matchingKey;
Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Grammar/Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
* @param array|null $attributes
* @return bool
*/
public function match($key, array $attributes = null, $bucketingKey = null)
public function match($key, ?array $attributes = null, $bucketingKey = null)

Check failure on line 71 in src/SplitIO/Grammar/Condition.php

View check run for this annotation

SonarQube Pull Requests / SonarQube Code Analysis

Refactor this function to reduce its Cognitive Complexity from 30 to the 15 allowed.

[S3776] Cognitive Complexity of functions should not be too high See more on https://sonar.harness.io/project/issues?id=splitsoftware_split-sdk-php&pullRequest=242&issues=42d2defa-d093-477f-89c7-9f1311ec13c6&open=42d2defa-d093-477f-89c7-9f1311ec13c6
{
$eval = array();
foreach ($this->matcherGroup as $matcher) {
Expand Down
28 changes: 14 additions & 14 deletions src/SplitIO/Sdk/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
*
* @return null|mixed
*/
private function doInputValidationForTreatment($key, $featureFlagName, array $attributes = null, $operation)
private function doInputValidationForTreatment($key, $featureFlagName, $operation, ?array $attributes = null)

Check warning on line 77 in src/SplitIO/Sdk/Client.php

View check run for this annotation

SonarQube Pull Requests / SonarQube Code Analysis

This method has 4 returns, which is more than the 3 allowed.

[S1142] Functions should not contain too many return statements See more on https://sonar.harness.io/project/issues?id=splitsoftware_split-sdk-php&pullRequest=242&issues=b55eec97-4d0b-4619-8cef-3cffdd7243c9&open=b55eec97-4d0b-4619-8cef-3cffdd7243c9
{
$key = InputValidator::validateKey($key, $operation);
if (is_null($key)) {
Expand Down Expand Up @@ -112,7 +112,7 @@
{
$default = array('treatment' => TreatmentEnum::CONTROL, 'config' => null);

$inputValidation = $this->doInputValidationForTreatment($key, $featureFlagName, $attributes, $operation);
$inputValidation = $this->doInputValidationForTreatment($key, $featureFlagName, $operation, $attributes);
if (is_null($inputValidation)) {
return $default;
}
Expand Down Expand Up @@ -169,7 +169,7 @@
/**
* @inheritdoc
*/
public function getTreatment($key, $featureName, array $attributes = null)
public function getTreatment($key, $featureName, ?array $attributes = null)
{
try {
$result = $this->doEvaluation(
Expand All @@ -188,7 +188,7 @@
/**
* @inheritdoc
*/
public function getTreatmentWithConfig($key, $featureFlagName, array $attributes = null)
public function getTreatmentWithConfig($key, $featureFlagName, ?array $attributes = null)
{
try {
return $this->doEvaluation(
Expand All @@ -213,7 +213,7 @@
*
* @return null|mixed
*/
private function doInputValidationForTreatments($key, $featureFlagNames, array $attributes = null, $operation)
private function doInputValidationForTreatments($key, $featureFlagNames, $operation, ?array $attributes = null)
{
$featureFlags = InputValidator::validateFeatureFlagNames($featureFlagNames, $operation);
if (is_null($featureFlags)) {
Expand Down Expand Up @@ -264,7 +264,7 @@
*/
private function doEvaluationForTreatments($operation, $key, $featureFlagNames, $attributes)
{
$inputValidation = $this->doInputValidationForTreatments($key, $featureFlagNames, $attributes, $operation);
$inputValidation = $this->doInputValidationForTreatments($key, $featureFlagNames, $operation, $attributes);
if (is_null($inputValidation)) {
return array();
}
Expand Down Expand Up @@ -301,7 +301,7 @@
/**
* @inheritdoc
*/
public function getTreatments($key, $featureFlagNames, array $attributes = null)
public function getTreatments($key, $featureFlagNames, ?array $attributes = null)
{
try {
return array_map(
Expand All @@ -325,7 +325,7 @@
/**
* @inheritdoc
*/
public function getTreatmentsWithConfig($key, $featureFlagNames, array $attributes = null)
public function getTreatmentsWithConfig($key, $featureFlagNames, ?array $attributes = null)
{
try {
return $this->doEvaluationForTreatments(
Expand Down Expand Up @@ -396,7 +396,7 @@
return false;
}

public function getTreatmentsByFlagSets($key, $flagSets, array $attributes = null)
public function getTreatmentsByFlagSets($key, $flagSets, ?array $attributes = null)
{
try {
return array_map(
Expand All @@ -416,7 +416,7 @@
}
}

public function getTreatmentsWithConfigByFlagSets($key, $flagSets, array $attributes = null)
public function getTreatmentsWithConfigByFlagSets($key, $flagSets, ?array $attributes = null)
{
try {
return $this->doEvaluationByFlagSets(
Expand All @@ -431,7 +431,7 @@
}
}

public function getTreatmentsByFlagSet($key, $flagSet, array $attributes = null)
public function getTreatmentsByFlagSet($key, $flagSet, ?array $attributes = null)
{
try {
return array_map(
Expand All @@ -451,7 +451,7 @@
}
}

public function getTreatmentsWithConfigByFlagSet($key, $flagSet, array $attributes = null)
public function getTreatmentsWithConfigByFlagSet($key, $flagSet, ?array $attributes = null)
{
try {
return $this->doEvaluationByFlagSets(
Expand All @@ -466,7 +466,7 @@
}
}

private function doInputValidationByFlagSets($key, $flagSets, array $attributes = null, $operation)
private function doInputValidationByFlagSets($key, $flagSets, $operation, ?array $attributes = null)
{
$key = InputValidator::validateKey($key, $operation);
if (is_null($key) || !InputValidator::validAttributes($attributes, $operation)) {
Expand All @@ -487,7 +487,7 @@

private function doEvaluationByFlagSets($operation, $key, $flagSets, $attributes)
{
$inputValidation = $this->doInputValidationByFlagSets($key, $flagSets, $attributes, $operation);
$inputValidation = $this->doInputValidationByFlagSets($key, $flagSets, $operation, $attributes);
if (is_null($inputValidation)) {
return array();
}
Expand Down
16 changes: 8 additions & 8 deletions src/SplitIO/Sdk/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface ClientInterface
* @param $attributes
* @return string
*/
public function getTreatment($key, $featureFlagName, array $attributes = null);
public function getTreatment($key, $featureFlagName, ?array $attributes = null);

/**
* Returns an object with the treatment to show this id for this feature
Expand Down Expand Up @@ -76,7 +76,7 @@ public function getTreatment($key, $featureFlagName, array $attributes = null);
* @param $attributes
* @return array
*/
public function getTreatmentWithConfig($key, $featureFlagName, array $attributes = null);
public function getTreatmentWithConfig($key, $featureFlagName, ?array $attributes = null);

/**
* Returns an associative array which each key will be
Expand Down Expand Up @@ -109,7 +109,7 @@ public function getTreatmentWithConfig($key, $featureFlagName, array $attributes
* @param $attributes
* @return array
*/
public function getTreatments($key, $featureFlagNames, array $attributes = null);
public function getTreatments($key, $featureFlagNames, ?array $attributes = null);

/**
* Returns an associative array which each key will be
Expand Down Expand Up @@ -144,7 +144,7 @@ public function getTreatments($key, $featureFlagNames, array $attributes = null)
* @param $attributes
* @return array
*/
public function getTreatmentsWithConfig($key, $featureFlagNames, array $attributes = null);
public function getTreatmentsWithConfig($key, $featureFlagNames, ?array $attributes = null);

/**
* Returns an associative array which each key will be
Expand Down Expand Up @@ -172,7 +172,7 @@ public function getTreatmentsWithConfig($key, $featureFlagNames, array $attribut
* @param $attributes
* @return array
*/
public function getTreatmentsWithConfigByFlagSets($key, $flagSets, array $attributes = null);
public function getTreatmentsWithConfigByFlagSets($key, $flagSets, ?array $attributes = null);

/**
* Returns an associative array which each key will be
Expand Down Expand Up @@ -200,7 +200,7 @@ public function getTreatmentsWithConfigByFlagSets($key, $flagSets, array $attrib
* @param $attributes
* @return array
*/
public function getTreatmentsByFlagSets($key, $flagSets, array $attributes = null);
public function getTreatmentsByFlagSets($key, $flagSets, ?array $attributes = null);

/**
* Returns an associative array which each key will be
Expand Down Expand Up @@ -234,7 +234,7 @@ public function getTreatmentsByFlagSets($key, $flagSets, array $attributes = nul
* @param $attributes
* @return array
*/
public function getTreatmentsByFlagSet($key, $flagSet, array $attributes = null);
public function getTreatmentsByFlagSet($key, $flagSet, ?array $attributes = null);

/**
* Returns an associative array which each key will be
Expand Down Expand Up @@ -262,7 +262,7 @@ public function getTreatmentsByFlagSet($key, $flagSet, array $attributes = null)
* @param $attributes
* @return array
*/
public function getTreatmentsWithConfigByFlagSet($key, $flagSet, array $attributes = null);
public function getTreatmentsWithConfigByFlagSet($key, $flagSet, ?array $attributes = null);

/**
* A short-hand for
Expand Down
8 changes: 4 additions & 4 deletions src/SplitIO/Sdk/Evaluator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private function fetchFeatureFlagNamesByFlagSets($flagSets)
return array_values(array_unique($toReturn));
}

public function evaluateFeature($matchingKey, $bucketingKey, $featureName, array $attributes = null)
public function evaluateFeature($matchingKey, $bucketingKey, $featureName, ?array $attributes = null)
{
$timeStart = Metrics::startMeasuringLatency();
$split = $this->fetchSplit($featureName);
Expand All @@ -72,7 +72,7 @@ public function evaluateFeature($matchingKey, $bucketingKey, $featureName, array
return $toReturn;
}

public function evaluateFeatures($matchingKey, $bucketingKey, array $featureNames, array $attributes = null)
public function evaluateFeatures($matchingKey, $bucketingKey, array $featureNames, ?array $attributes = null)
{
$toReturn = array(
'evaluations' => array(),
Expand All @@ -86,7 +86,7 @@ public function evaluateFeatures($matchingKey, $bucketingKey, array $featureName
return $toReturn;
}

public function evaluateFeaturesByFlagSets($matchingKey, $bucketingKey, array $flagSets, array $attributes = null)
public function evaluateFeaturesByFlagSets($matchingKey, $bucketingKey, array $flagSets, ?array $attributes = null)
{
$timeStart = Metrics::startMeasuringLatency();
$featureFlagNames = $this->fetchFeatureFlagNamesByFlagSets($flagSets);
Expand All @@ -95,7 +95,7 @@ public function evaluateFeaturesByFlagSets($matchingKey, $bucketingKey, array $f
return $toReturn;
}

private function evalTreatment($key, $bucketingKey, $split, array $attributes = null)
private function evalTreatment($key, $bucketingKey, $split, ?array $attributes = null)
{
$result = array(
'treatment' => TreatmentEnum::CONTROL,
Expand Down
16 changes: 8 additions & 8 deletions src/SplitIO/Sdk/LocalhostClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
/**
* @inheritdoc
*/
public function getTreatment($key, $featureFlagName, array $attributes = null)
public function getTreatment($key, $featureFlagName, ?array $attributes = null)

Check warning on line 139 in src/SplitIO/Sdk/LocalhostClient.php

View check run for this annotation

SonarQube Pull Requests / SonarQube Code Analysis

This method has 4 returns, which is more than the 3 allowed.

[S1142] Functions should not contain too many return statements See more on https://sonar.harness.io/project/issues?id=splitsoftware_split-sdk-php&pullRequest=242&issues=3048c7d2-4e1d-4b27-93b9-159ed62f094f&open=3048c7d2-4e1d-4b27-93b9-159ed62f094f
{
$key = $this->doValidation($key, $featureFlagName, "getTreatment");
if (is_null($key)) {
Expand All @@ -157,7 +157,7 @@
/**
* @inheritdoc
*/
public function getTreatmentWithConfig($key, $featureFlagName, array $attributes = null)
public function getTreatmentWithConfig($key, $featureFlagName, ?array $attributes = null)
{
$treatmentResult = array(
"treatment" => TreatmentEnum::CONTROL,
Expand Down Expand Up @@ -189,7 +189,7 @@
/**
* @inheritdoc
*/
public function getTreatments($key, $featureFlagNames, array $attributes = null)
public function getTreatments($key, $featureFlagNames, ?array $attributes = null)
{
$result = array();

Expand All @@ -213,7 +213,7 @@
/**
* @inheritdoc
*/
public function getTreatmentsWithConfig($key, $featureFlagNames, array $attributes = null)
public function getTreatmentsWithConfig($key, $featureFlagNames, ?array $attributes = null)
{
$result = array();

Expand Down Expand Up @@ -258,25 +258,25 @@
return true;
}

public function getTreatmentsWithConfigByFlagSets($key, $flagSets, array $attributes = null)
public function getTreatmentsWithConfigByFlagSets($key, $flagSets, ?array $attributes = null)
{
// no-op
return array();
}

public function getTreatmentsByFlagSets($key, $flagSets, array $attributes = null)
public function getTreatmentsByFlagSets($key, $flagSets, ?array $attributes = null)
{
// no-op
return array();
}

public function getTreatmentsWithConfigByFlagSet($key, $flagSet, array $attributes = null)
public function getTreatmentsWithConfigByFlagSet($key, $flagSet, ?array $attributes = null)
{
// no-op
return array();
}

public function getTreatmentsByFlagSet($key, $flagSet, array $attributes = null)
public function getTreatmentsByFlagSet($key, $flagSet, ?array $attributes = null)
{
// no-op
return array();
Expand Down
Loading