Skip to content

Commit d3dd25c

Browse files
committed
updated with latest in master
2 parents 0869c91 + cd9133b commit d3dd25c

29 files changed

+341
-331
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ on:
66
- master
77
push:
88
branches:
9+
- develop
910
- master
1011

12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
14+
cancel-in-progress: true
15+
1116
jobs:
1217
build:
1318
name: Build
@@ -18,69 +23,63 @@ jobs:
1823
ports:
1924
- 6379:6379
2025
strategy:
26+
fail-fast: false
2127
matrix:
22-
version: ['7.4', '8.0', '8.1', '8.2']
28+
version:
29+
- '7.3'
30+
- '8.0'
31+
- '8.1'
32+
- '8.2'
2333
steps:
2434
- name: Checkout code
2535
uses: actions/checkout@v3
36+
with:
37+
fetch-depth: 0
2638

2739
- name: Setup PHP
2840
uses: shivammathur/setup-php@v2
2941
with:
3042
php-version: ${{ matrix.version }}
3143
extensions: mbstring, intl
3244
ini-values: post_max_size=256M, max_execution_time=180
33-
coverage: xdebug
45+
coverage: pcov
3446

3547
- name: Install dependencies
3648
run: |
3749
composer install --prefer-dist
3850
composer update
39-
composer dumpautoload
4051
4152
- name: Build
4253
run: |
4354
vendor/bin/phpcs --ignore=functions.php --standard=PSR2 src/
44-
vendor/bin/phpunit -c phpunit.xml.dist -v --testsuite integration
55+
vendor/bin/phpunit -c phpunit.xml.dist -v --testsuite integration --coverage-clover coverage.xml
4556
46-
sonarqube:
47-
name: Sonarqube
48-
runs-on: ubuntu-latest
49-
steps:
50-
- name: Checkout code
51-
uses: actions/checkout@v3
52-
with:
53-
fetch-depth: 0
57+
- name: Set VERSION env
58+
run: echo "VERSION=$(cat src/SplitIO/Version.php | grep 'const CURRENT' | cut -d "'" -f 2 | sed "s/'//g")" >> $GITHUB_ENV
5459

5560
- name: SonarQube Scan (Push)
56-
if: github.event_name == 'push'
57-
uses: SonarSource/sonarcloud-github-action@v1.5
61+
if: matrix.version == '8.2' && github.event_name == 'push'
62+
uses: SonarSource/sonarcloud-github-action@v1.9
5863
env:
5964
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6066
with:
6167
projectBaseDir: .
6268
args: >
6369
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
64-
-Dsonar.projectName=${{ github.event.repository.name }}
65-
-Dsonar.projectKey=splitsoftware_split-sdk-php
66-
-Dsonar.exclusions="**/tests/**/*.*"
67-
-Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions"
68-
-Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}"
70+
-Dsonar.projectVersion=${{ env.VERSION }}
6971
7072
- name: SonarQube Scan (Pull Request)
71-
if: github.event_name == 'pull_request'
72-
uses: SonarSource/sonarcloud-github-action@v1.5
73+
if: matrix.version == '8.2' && github.event_name == 'pull_request'
74+
uses: SonarSource/sonarcloud-github-action@v1.9
7375
env:
7476
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7578
with:
7679
projectBaseDir: .
7780
args: >
7881
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
79-
-Dsonar.projectName=${{ github.event.repository.name }}
80-
-Dsonar.projectKey=splitsoftware_split-sdk-php
81-
-Dsonar.exclusions="**/tests/**/*.*"
82-
-Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions"
83-
-Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}"
82+
-Dsonar.projectVersion=${{ env.VERSION }}
8483
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
8584
-Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }}
86-
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}
85+
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}

.github/workflows/update-license-year.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
uses: actions/checkout@v3
1717
with:
1818
fetch-depth: 0
19-
19+
2020
- name: Set Current year
2121
run: "echo CURRENT=$(date +%Y) >> $GITHUB_ENV"
22-
22+
2323
- name: Set Previous Year
2424
run: "echo PREVIOUS=$(($CURRENT-1)) >> $GITHUB_ENV"
2525

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ test.php
2626

2727
# Sonarqube
2828
.scannerwork
29+
30+
# Tests
31+
.phpunit.result.cache
32+
coverage.xml

CHANGES.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
- BREAKING CHANGE: Removed support from versions older than PHP 7.4.
33
- BREAKING CHANGE: Added support for Multiple Factory Instantiation.
44

5+
7.1.7 (May 16, 2023)
6+
- Updated terminology on the SDKs codebase to be more aligned with current standard without causing a breaking change. The core change is the term split for feature flag on things like logs and phpdoc comments.
7+
- Fixed php 8.2 warnings in code.
8+
59
7.1.6 (Feb 14, 2023)
610
- Fixed logging on array conversion.
711

@@ -45,7 +49,7 @@
4549
- Added flag `IPAddressesEnabled` into options to enable/disable sending MachineName and MachineIP when data is posted in headers.
4650

4751
6.2.2 (Sep 18, 2019)
48-
- Fetch multiple splits at once on getTreatments/getTreatmentsWithConfig
52+
- Fetch multiple feature flags at once on getTreatments/getTreatmentsWithConfig
4953
- Removed MatcherClient (DependencyMatcher now uses Evaluator directly)
5054
- Removed shared memory.
5155
- Several code cleanups
@@ -56,7 +60,7 @@
5660

5761
6.2.0 (May 30, 2019)
5862
- Added validation for TrafficType in track calls.
59-
- Added validation when split does not exist on treatments and manager calls.
63+
- Added validation when feature flag does not exist on treatments and manager calls.
6064
- Added multiple factory instantiation check.
6165
- Removed producer modules.
6266
- Added properties to track method.
@@ -98,7 +102,7 @@
98102
- Downgrade logging level for shared memory messages
99103

100104
5.2.3: (Sep 5, 2017)
101-
- Adding hotfix to return empty splits array in SplitManager when redis is empty.
105+
- Adding hotfix to return empty feature flags array in SplitManager when redis is empty.
102106

103107
5.2.2: (Aug 1, 2017)
104108
- Adding hotfix to return CONTROL if redis is down instead of failing.

README.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44
[![Latest stable](https://img.shields.io/packagist/v/splitsoftware/split-sdk-php)](https://packagist.org/packages/splitsoftware/split-sdk-php)
55
[![Documentation](https://img.shields.io/badge/php_client-documentation-informational)](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
66

7-
This SDK is designed to work with Split, the platform for controlled rollouts, serving features to your users via the Split feature flag to manage your complete customer experience.
7+
## Overview
8+
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.
89

910
## Compatibility
1011
This SDK is compatible with PHP 7.3 and above.
1112

1213
## Getting started
1314
Below is a simple example that describes the instantiation and most basic usage of our SDK.
14-
Keep in mind that since PHP does not have the ability to share memory between processes the use of the [split-synchronizer](https://help.split.io/hc/en-us/articles/360019686092-Split-Synchronizer-Proxy) is mandatory for this SDK.
15+
Keep in mind that since PHP does not have the ability to share memory between processes the use of the [split-synchronizer](https://help.split.io/hc/en-us/articles/360019686092-Split-Synchronizer) is mandatory for this SDK.
1516

1617
```php
1718
<?php
1819

1920
$sdkConfig = ['cache' => ['adapter' => 'predis']];
20-
$splitFactory = \SplitIO\Sdk::factory('SDK_API_KEY', $sdkConfig);
21+
$splitFactory = \SplitIO\Sdk::factory('YOUR_SDK_KEY', $sdkConfig);
2122

2223
$splitClient = $splitFactory->client();
23-
$treatment = $splitClient->getTreatment('CUSTOMER_ID','SPLIT_NAME');
24+
$treatment = $splitClient->getTreatment('CUSTOMER_ID','FEATURE_FLAG_NAME');
2425
if ($treatment === 'on') {
2526
// Feature is enabled for this user!
2627
} elseif ($treatment === 'off') {
@@ -30,9 +31,11 @@ if ($treatment === 'on') {
3031
}
3132
```
3233

34+
Please refer to [our official docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK) to learn about all the functionality provided by our SDK and the configuration options available for tailoring it to your current application setup.
35+
3336
## Submitting issues
3437

35-
The Split team monitors all issues submitted to this [issue tracker](https://github.com/splitio/php-client/issues). We encourage you to use this issue tracker to submit any bug reports, feedback, and feature enhancements. We'll do our best to respond in a timely manner.
38+
The Split team monitors all issues submitted to this [issue tracker](https://github.com/splitio/php-client/issues). We encourage you to use this issue tracker to submit any bug reports, feedback, and feature enhancements. We'll do our best to respond in a timely manner.
3639

3740
## Contributing
3841
Please see [Contributors Guide](CONTRIBUTORS-GUIDE.md) to find all you need to submit a Pull Request (PR).
@@ -41,26 +44,31 @@ Please see [Contributors Guide](CONTRIBUTORS-GUIDE.md) to find all you need to s
4144
Licensed under the Apache License, Version 2.0. See: [Apache License](http://www.apache.org/licenses/).
4245

4346
## About Split
44-
47+
4548
Split is the leading Feature Delivery Platform for engineering teams that want to confidently deploy features as fast as they can develop them. Split’s fine-grained management, real-time monitoring, and data-driven experimentation ensure that new features will improve the customer experience without breaking or degrading performance. Companies like Twilio, Salesforce, GoDaddy and WePay trust Split to power their feature delivery.
46-
49+
4750
To learn more about Split, contact hello@split.io, or get started with feature flags for free at https://www.split.io/signup.
48-
51+
4952
Split has built and maintains SDKs for:
50-
53+
54+
* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
55+
* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
56+
* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
57+
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
58+
* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
5159
* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
52-
* Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
60+
* JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
61+
* JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
5362
* Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
54-
* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
55-
* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
5663
* PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
5764
* Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
58-
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
59-
* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
60-
* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
61-
65+
* React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK)
66+
* React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK)
67+
* Redux [Github](https://github.com/splitio/redux-client) [Docs](https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK)
68+
* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
69+
6270
For a comprehensive list of open source projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).
63-
71+
6472
**Learn more about Split:**
65-
73+
6674
Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [help.split.io](http://help.split.io) for more detailed information.

bin/splitio.dist.ini

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
;NOTE: This file is read by default. If you would like customize it, please copy this file and replace the values.
1111
;
1212

13-
;API-KEY for Split environment
14-
api-key = 'YOUR_SPLITIO_APIKEY'
13+
;SDK-KEY for Split environment
14+
sdk-key = 'YOUR_SDK_KEY'
1515

1616
;---------------------
1717
;LOG configuration
@@ -53,26 +53,3 @@ log-level = 'error'
5353
cache-adapter = 'predis'
5454
predis-parameters = '{"scheme":"tcp","host":"localhost","port":6379,"timeout":881}'
5555
predis-options = '{"prefix":""}'
56-
57-
58-
;---------------------
59-
;PROCESS configuration
60-
;---------------------
61-
62-
;SPLITS
63-
;Set the rate to fetch the Splits definitions from server
64-
features-refresh-rate = 30
65-
66-
;SEGMENTS
67-
;Set the rate to fetch the Segments keys from server
68-
segments-refresh-rate = 60
69-
70-
;IMPRESSIONS
71-
;Set the rate to send the treatments impressions to server
72-
impressions-refresh-rate = 60
73-
74-
;METRICS
75-
;Set the rate to send the SDK metrics to server
76-
metrics-refresh-rate = 60
77-
78-

phpunit.xml.dist

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
<const name="TEST_PREFIX" value="SPLITIO_TEST:."/>
99
</php>
1010

11+
<filter>
12+
<whitelist>
13+
<directory suffix=".php">src</directory>
14+
</whitelist>
15+
</filter>
16+
1117
<testsuites>
1218
<testsuite name="splitio">
1319
<directory suffix="Test.php">tests/</directory>
@@ -49,8 +55,6 @@
4955
<directory suffix="Test.php">tests/Suite/Sdk/</directory>
5056
</testsuite>
5157

52-
53-
5458
<testsuite name="integration">
5559
<directory suffix="Test.php">tests/Suite/Adapter/</directory>
5660
<directory suffix="Test.php">tests/Suite/Attributes/</directory>

sonar-project.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
sonar.projectName=php-client
2+
sonar.projectKey=splitsoftware_split-sdk-php
3+
sonar.sources=src
4+
sonar.tests=tests
5+
sonar.php.coverage.reportPaths=coverage.xml
6+
sonar.links.ci=https://github.com/splitio/php-client
7+
sonar.links.scm=https://github.com/splitio/php-client/actions

src/SplitIO/Component/Cache/SplitCache.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ public function getSplit($splitName)
6868
*/
6969
public function getSplits($splitNames)
7070
{
71-
$cacheItems = $this->cache->fetchMany(array_map(self::class . '::getCacheKeyForSplit', $splitNames));
71+
$cacheItems = $this->cache->fetchMany(array_map([
72+
self::class, 'getCacheKeyForSplit'
73+
], $splitNames));
7274
$toReturn = array();
7375
foreach ($cacheItems as $key => $value) {
7476
$toReturn[self::getSplitNameFromCacheKey($key)] = $value;
@@ -81,8 +83,8 @@ public function getSplits($splitNames)
8183
*/
8284
public function getSplitNames()
8385
{
84-
$splitKeys = $this->cache->getKeys(self::getCacheKeySearchPattern());
85-
return array_map('self::getSplitNameFromCacheKey', $splitKeys);
86+
$splitKeys = $this->cache->getKeys(self::getCacheKeySearchPattern());
87+
return array_map([self::class, 'getSplitNameFromCacheKey'], $splitKeys);
8688
}
8789

8890
/**

src/SplitIO/Component/Common/Context.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
class Context
1212
{
13-
const SAME_APIKEY = "Factory Instantiation: You already have %s factory/factories with this API Key. "
13+
const SAME_SDK_KEY = "Factory Instantiation: You already have %s factory/factories with this SDK Key. "
1414
. "We recommend keeping only one instance of the factory at all times (Singleton pattern) and "
1515
. "reusing it throughout your application.";
1616

@@ -72,19 +72,19 @@ public function __wakeup()
7272
}
7373

7474
/**
75-
* @param string $apiKey
75+
* @param string $sdkKey
7676
* @return int
7777
*/
78-
public static function trackFactory($apiKey)
78+
public static function trackFactory($sdkKey)
7979
{
80-
$current = self::getInstance()->factoryTracker[$apiKey] ?? 0;
80+
$current = self::getInstance()->factoryTracker[$sdkKey] ?? 0;
8181
if ($current > 0) {
82-
self::getInstance()->getLogger()->warning(sprintf(self::SAME_APIKEY, $current));
82+
self::getInstance()->getLogger()->warning(sprintf(self::SAME_SDK_KEY, $current));
8383
} elseif (count(self::getInstance()->factoryTracker) > 0) {
8484
self::getInstance()->getLogger()->warning(self::MULTIPLE_INSTANCES);
8585
}
8686
$current += 1;
87-
self::getInstance()->factoryTracker[$apiKey] = $current;
87+
self::getInstance()->factoryTracker[$sdkKey] = $current;
8888
return $current;
8989
}
9090

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
class ContainsString extends AbstractMatcher
77
{
8-
protected $ContainsStringMatcherData = null;
9-
10-
private $containsStringMatcherData;
8+
private $containsStringMatcherData = null;
119

1210
public function __construct($data, $negate = false, $attribute = null)
1311
{

src/SplitIO/Grammar/Split.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(array $split)
5151
$this->configurations = isset($split['configurations']) && count($split['configurations']) > 0 ?
5252
$split['configurations'] : null;
5353

54-
SplitApp::logger()->info("Constructing Split: ".$this->name);
54+
SplitApp::logger()->info("Constructing Feature Flag: ".$this->name);
5555

5656
if (isset($split['conditions']) && is_array($split['conditions'])) {
5757
$this->conditions = array();

0 commit comments

Comments
 (0)