diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fed4af2d..42049106 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,8 @@ jobs: - '8.1' - '8.2' - '8.3' + - '8.4' + - '8.5' steps: - name: Checkout code uses: actions/checkout@v3 @@ -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 }} @@ -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 }} diff --git a/README.md b/README.md index daa54d57..701b5dce 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/SplitIO/Component/Log/Logger.php b/src/SplitIO/Component/Log/Logger.php index d05dddb1..1c0735d9 100644 --- a/src/SplitIO/Component/Log/Logger.php +++ b/src/SplitIO/Component/Log/Logger.php @@ -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]; diff --git a/src/SplitIO/Engine.php b/src/SplitIO/Engine.php index d539fe8c..f4cd9b28 100644 --- a/src/SplitIO/Engine.php +++ b/src/SplitIO/Engine.php @@ -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; diff --git a/src/SplitIO/Grammar/Condition.php b/src/SplitIO/Grammar/Condition.php index 7266c5e3..3d40083f 100644 --- a/src/SplitIO/Grammar/Condition.php +++ b/src/SplitIO/Grammar/Condition.php @@ -68,7 +68,7 @@ public function __construct(array $condition) * @param array|null $attributes * @return bool */ - public function match($key, array $attributes = null, $bucketingKey = null) + public function match($key, ?array $attributes = null, $bucketingKey = null) { $eval = array(); foreach ($this->matcherGroup as $matcher) { diff --git a/src/SplitIO/Sdk/Client.php b/src/SplitIO/Sdk/Client.php index 0b7e2dd5..e21432d4 100644 --- a/src/SplitIO/Sdk/Client.php +++ b/src/SplitIO/Sdk/Client.php @@ -74,7 +74,7 @@ private function createImpression($key, $featureFlag, $treatment, $changeNumber, * * @return null|mixed */ - private function doInputValidationForTreatment($key, $featureFlagName, array $attributes = null, $operation) + private function doInputValidationForTreatment($key, $featureFlagName, $operation, ?array $attributes = null) { $key = InputValidator::validateKey($key, $operation); if (is_null($key)) { @@ -112,7 +112,7 @@ private function doEvaluation($operation, $key, $featureFlagName, $attributes) { $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; } @@ -169,7 +169,7 @@ private function doEvaluation($operation, $key, $featureFlagName, $attributes) /** * @inheritdoc */ - public function getTreatment($key, $featureName, array $attributes = null) + public function getTreatment($key, $featureName, ?array $attributes = null) { try { $result = $this->doEvaluation( @@ -188,7 +188,7 @@ public function getTreatment($key, $featureName, array $attributes = null) /** * @inheritdoc */ - public function getTreatmentWithConfig($key, $featureFlagName, array $attributes = null) + public function getTreatmentWithConfig($key, $featureFlagName, ?array $attributes = null) { try { return $this->doEvaluation( @@ -213,7 +213,7 @@ public function getTreatmentWithConfig($key, $featureFlagName, array $attributes * * @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)) { @@ -264,7 +264,7 @@ private function registerData($impressions, $attributes) */ 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(); } @@ -301,7 +301,7 @@ private function doEvaluationForTreatments($operation, $key, $featureFlagNames, /** * @inheritdoc */ - public function getTreatments($key, $featureFlagNames, array $attributes = null) + public function getTreatments($key, $featureFlagNames, ?array $attributes = null) { try { return array_map( @@ -325,7 +325,7 @@ function ($feature) { /** * @inheritdoc */ - public function getTreatmentsWithConfig($key, $featureFlagNames, array $attributes = null) + public function getTreatmentsWithConfig($key, $featureFlagNames, ?array $attributes = null) { try { return $this->doEvaluationForTreatments( @@ -396,7 +396,7 @@ public function track($key, $trafficType, $eventType, $value = null, $properties return false; } - public function getTreatmentsByFlagSets($key, $flagSets, array $attributes = null) + public function getTreatmentsByFlagSets($key, $flagSets, ?array $attributes = null) { try { return array_map( @@ -416,7 +416,7 @@ function ($feature) { } } - public function getTreatmentsWithConfigByFlagSets($key, $flagSets, array $attributes = null) + public function getTreatmentsWithConfigByFlagSets($key, $flagSets, ?array $attributes = null) { try { return $this->doEvaluationByFlagSets( @@ -431,7 +431,7 @@ public function getTreatmentsWithConfigByFlagSets($key, $flagSets, array $attrib } } - public function getTreatmentsByFlagSet($key, $flagSet, array $attributes = null) + public function getTreatmentsByFlagSet($key, $flagSet, ?array $attributes = null) { try { return array_map( @@ -451,7 +451,7 @@ function ($feature) { } } - public function getTreatmentsWithConfigByFlagSet($key, $flagSet, array $attributes = null) + public function getTreatmentsWithConfigByFlagSet($key, $flagSet, ?array $attributes = null) { try { return $this->doEvaluationByFlagSets( @@ -466,7 +466,7 @@ public function getTreatmentsWithConfigByFlagSet($key, $flagSet, array $attribut } } - 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)) { @@ -487,7 +487,7 @@ private function doInputValidationByFlagSets($key, $flagSets, array $attributes 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(); } diff --git a/src/SplitIO/Sdk/ClientInterface.php b/src/SplitIO/Sdk/ClientInterface.php index d661d143..36cb950b 100644 --- a/src/SplitIO/Sdk/ClientInterface.php +++ b/src/SplitIO/Sdk/ClientInterface.php @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/SplitIO/Sdk/Evaluator.php b/src/SplitIO/Sdk/Evaluator.php index 5e754d6d..a403278d 100644 --- a/src/SplitIO/Sdk/Evaluator.php +++ b/src/SplitIO/Sdk/Evaluator.php @@ -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); @@ -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(), @@ -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); @@ -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, diff --git a/src/SplitIO/Sdk/LocalhostClient.php b/src/SplitIO/Sdk/LocalhostClient.php index b9e13a83..d0ac56fe 100644 --- a/src/SplitIO/Sdk/LocalhostClient.php +++ b/src/SplitIO/Sdk/LocalhostClient.php @@ -136,7 +136,7 @@ public function doValidation($key, $featureFlagName, $operation) /** * @inheritdoc */ - public function getTreatment($key, $featureFlagName, array $attributes = null) + public function getTreatment($key, $featureFlagName, ?array $attributes = null) { $key = $this->doValidation($key, $featureFlagName, "getTreatment"); if (is_null($key)) { @@ -157,7 +157,7 @@ public function getTreatment($key, $featureFlagName, array $attributes = null) /** * @inheritdoc */ - public function getTreatmentWithConfig($key, $featureFlagName, array $attributes = null) + public function getTreatmentWithConfig($key, $featureFlagName, ?array $attributes = null) { $treatmentResult = array( "treatment" => TreatmentEnum::CONTROL, @@ -189,7 +189,7 @@ public function getTreatmentWithConfig($key, $featureFlagName, array $attributes /** * @inheritdoc */ - public function getTreatments($key, $featureFlagNames, array $attributes = null) + public function getTreatments($key, $featureFlagNames, ?array $attributes = null) { $result = array(); @@ -213,7 +213,7 @@ public function getTreatments($key, $featureFlagNames, array $attributes = null) /** * @inheritdoc */ - public function getTreatmentsWithConfig($key, $featureFlagNames, array $attributes = null) + public function getTreatmentsWithConfig($key, $featureFlagNames, ?array $attributes = null) { $result = array(); @@ -258,25 +258,25 @@ public function track($key, $trafficType, $eventType, $value = null) 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();